//tslint:disable
import { ModalOfMultipleComponent } from './../post-edit-form/modal-of-multiple/modal-of-multiple.component';
import { Component, Input, OnInit } from "@angular/core";

import { ModalController } from '@ionic/angular';

import { ChooseCityComponent } from '../choose-city/choose-city.component';
import { ChooseDepartmentComponent } from '../choose-department/choose-department.component';
import { SearchFilterComponent } from '../search-filter/search-filter.component';
import { AppGlobalService } from "../../shared/service/app-global.service";
import { HttpService } from "../../shared/service/http.service";
import { MessageService } from "../../shared/service/message.service";
import { EventService } from 'src/app/shared/service/event.service';
import { Picker } from 'ng-zorro-antd-mobile';
import { FirstLevel } from "./firstLevel.model";
import { SiftModel } from "./sift.model";
import { isTabSwitch } from '@ionic/angular/dist/directives/navigation/stack-utils';
import { PageModalService } from 'src/app/shared/service/page-modal-service';

declare let $: any;
@Component({
  selector: "app-sift",
  templateUrl: "./sift.component.html",
  styleUrls: ["./sift.component.scss"],
  providers: [Picker]
})
export class SiftComponent implements OnInit {
  @Input() tagData: any;
  sessionId: string;
  siftArr: FirstLevel[]; // 筛选条件list
  siftArrtwo: any; // 循环筛选数据的数组
  siftArrthree: any; // 循环筛选数据关于事件的数组
  siftArrFourth: any; // 循环数据关于事件的数组
  siftTypeArr: any; // 转让or出租
  siftWidth: any; // 宽度
  openFlag = false; // 下级列表面板是否打开
  siftObj: FirstLevel; // 筛选条件
  firstLevelList: SiftModel[]; // 第一次选中元素
  firstLevelListNewCssType: SiftModel[]; // 第一次选中元素 // 1.9.0 5 新增行业
  firstLevelDistrictListNewCssType: SiftModel[]; // 第一次选中元素 // 1.9.0 5 新增区域
  firstLevelDistrictListNewCssType2: SiftModel[]; // 第一次选中元素 // 1.6.15 新增区域2
  multipleSelect3ListData: any;// 1.7.0 赚钱宝新增全部分类三级数据
  multipleSelect3FilterName: any;// 1.7.0 赚钱宝新增全部分类三级数据
  list: any = [];
  streamingLayoutList: any = [];// 1.9.0 5 新增整租合租
  rangeStreamingLayoutList: any = [];// 1.9.19 新增是否住家
  customAreaList: any = [];// 1.9.0 5 新增面积列表
  customRentList: any = [];// 1.9.0 5 新增租金列表
  brandLinkageData: any = [];// 品牌


  ifSecond: boolean; // 是否有二级列表
  ifLink: boolean; // 是否link
  secondLevelList: SiftModel[]; // 第一次选中元素
  selectedIndexName: any; // 选中的条件显
  selectedIndexDisplayName: any; // 选中的条件显
  // minArea: ""; // 自定义最小面积
  // maxArea: ""; // 自定义最大面积
  ifadvertis: any; // 选择月份还是天

  currentCity: any; // 当前城市

  showName: any;
  filterType: any = "transfer";
  minDate: any = "2018-05-01"; // 最小日期
  maxDate: any = "2021-12-23"; // 最大日期
  datetext: any = "0-0-0"; // 显示日期字段
  year: any = '0'; // 年
  month: any = '0'; // 月
  day: any = '0';  // 日
  datelabel: any; // 日期控件是否存在
  // 选中结果
  result: any = {
    showName: "",
    filter: {},
    order: {}
  };
  key: string;
  type: string; // 类型
  fristObj;
  siftArrPercent = '';
  showCustomPicker = false;
  cout = 2;
  switchBlockTag: any; // 蜂喔app新增首页tag样式
  subFilterItem: any; // 新增自定义日期选择控件
  siftDateFilterId = 'siftDateFilterId';
  isNewCssType = false;

  // 新增三种类型分筛选分类
  data: any; // 从sift组件传递的数组参数
  industryList: any;

  bigIndus: any = { background: false };
  selectIndus: any = [];
  industryArr: any = [];
  region: any = [];
  brandArr: any = [];
  checkedIndus: any = "";
  max = 5;
  industryMax = 5; // 行业 选中数量
  noDismiss: any;
  tip1 = '不能超过';
  tip2 = '个选中';
  // type = 'default'; // 默认类型 以后可以方便扩展为
  isLJModel = false;
  cssType: any; // 展示类型 是 区域 行业 （secondaryLinkage） 还是 整租合租 方式（streamingLayout） 还是 面积 customArea
  minInputValue = '';
  maxInputValue = '';
  minRentInputValue = '';
  maxRentInputValue = '';
  secondaryLinkageTitle: any; // 行业
  streamingLayoutTitle: any; // 整租、合租
  rangeStreamingLayoutTitle: any; // 是否住家
  customAreaTitle: any; // 自定义面积
  customRentTitle: any; // 自定义租金
  districtLinkageTitle: any;// 区域
  districtLinkageTitle2: any;// 区域
  brandLinkageTitle: any; // 品牌
  bigNameId = 'bigNameId';
  siftPanelShowing = false;// 是否正在显示 筛选面板
  districtLinkage2_submit = true;// 区域 是否需要请求
  secondaryLinkage_submit = true;// 行业 是否需要请求
  brandLinkage_submit = true;// 品牌 是否需要请求
  liveAtHome: any = [];
  rangeStreamValue = { lower: '6', upper: '22' };
  rangeStreamLower = '6'; //min默认值
  rangeStreamUpper = '22'; // 默认值

  constructor(
    private http: HttpService,
    private message: MessageService,
    private eventService: EventService,
    private modalController: ModalController,
    public appGlobalService: AppGlobalService,
    public pageModalService: PageModalService
  ) { }
  ngOnInit() {
    this.siftDateFilterId += new Date().getTime();
    this.bigNameId += new Date().getTime();
    if (this.tagData.switchBlockTag) {
      this.switchBlockTag = this.tagData.switchBlockTag;
    }
    this.sessionId = localStorage.getItem("sessionId");
    const searchArray = JSON.parse(localStorage.getItem("searchArray"));
    this.currentCity = JSON.parse(localStorage.getItem("position"));
    // this.showName = JSON.parse(localStorage.getItem('targetObj')).forward.params.showName;
    if (sessionStorage.getItem("showName") !== 'undefined' && sessionStorage.getItem("showName") !== null) {
      this.showName = sessionStorage.getItem("showName");
    }
    // this.demoData();
    /***
     * 日历相关
     */
    //  获取年月日
    const myDate = new Date();
    this.year = myDate.getFullYear();    // 获取完整的年份(4位,1970-????)
    this.month = myDate.getMonth() + 1;       // 获取当前月份(0-11,0代表1月)
    this.day = myDate.getDate();

    // old
    if (this.tagData.filterItems) {
      this.tagData.filterItems.forEach(element => {
        if (element.queryType === "dateFilter") {
          this.datelabel = true;
          this.maxDate = element.maxDate;
          this.minDate = element.minDate;
          element.dropDownList.item[0].value = this.datetext;
        }
      });
    } else {
      // new
      this.tagData.filterType.forEach(element => {
        if (element.active === '1' && element.filterItem) {
          this.tagData.filterItems = element.filterItem;
          element.filterItem.forEach(e => {
            if (e.queryType === "dateFilter") {
              this.datelabel = true;
              this.maxDate = e.maxDate;
              this.minDate = e.minDate;
              e.dropDownList.item[0].value = this.datetext;
            }
          });
        }
      });
    }
    this.ifadvertis = true; // 默认为按月
    if (this.ifadvertis === true) {
      this.datepk('month');
    } else {
      this.datepk('day');
    }
    this.initFilterData(searchArray);
    localStorage.removeItem("searchArray");


    // 1.7.0 新增分类筛选
    this.eventService.eventEmit.on('appendResultForSift', (res) => {
      if (res !== undefined) {
        this.result.filter[res.name] = res.value;
        this.getResult(this.result, 'multipleSelect3');
      }
    });

  }
  initFilterData(searchArray) {
    try {
      // 如果是newFilterTag 有条件显示下拉选项
      if (this.tagData.displayIndex && this.tagData.displayIndex.length > 0) {
        if (this.tagData.checkDefaultValue && this.tagData.defaultBusinessStatusIndex) {

          const currentIndex = parseInt(this.tagData.defaultBusinessStatusIndex) - 1;
          const defaultObj = this.tagData.displayIndex[0];
          this.tagData.displayIndex[0] = this.tagData.displayIndex[currentIndex];
          this.tagData.displayIndex[currentIndex] = defaultObj;
          this.tagData.filterItems[0].dropDownList.displayName = this.tagData.displayIndex[0].displayName;
        }

        // 获取第一列后面显示隐藏的条件
        this.tagData.displayIndex.forEach(element => {
          if (element.displayName === this.tagData.filterItems[0].dropDownList.displayName) {
            this.selectedIndexName = element.indexName;
            this.selectedIndexDisplayName = element.displayName;
          }

        });




        // 将要显示的条件列表加入
        this.siftArr = [];
        this.tagData.filterItems.forEach(element => {
          if (element.indexName && element.indexName === this.selectedIndexName) {
            this.siftArr.push(element);
          } else if (!element.indexName) {
            if (element.queryType && element.queryType === 'dateFilter') {
              this.siftArrtwo = [];
              this.siftArrthree = [];
              if (element.subFilterItem) {
                this.subFilterItem = element.subFilterItem[0];
                // this.siftArrFourth.push(element.subFilterItem);
              }
              this.siftArrthree.push(element);

            } else {
              this.siftArr.push(element);
            }

          }
        });
      } else {
        this.siftArrtwo = [];
        this.siftArrthree = [];
        this.siftArr = [];
        // filterItems里queryTypetype为dateFilter的类型特殊，故将该类型剔除，重新组装数据siftArrtwo在视图层循环li部分，而queryTypetype为dateFilter的类型数据储存在siftArrthree;
        /* this.siftArr = this.tagData.filterItems; */
        this.tagData.filterItems.forEach(element => {
          // console.log(element);
          if (element.queryType && element.queryType === 'dateFilter') {
            if (element.subFilterItem) {
              // this.siftArrFourth.push(element.subFilterItem);
              this.subFilterItem = element.subFilterItem[0];
            }
            this.siftArrthree.push(element);
          } else {
            if (element.link !== undefined && element.link.params && element.link.params.cssType !== undefined) {
              this.isNewCssType = true;
              if (element.link.params.cssType === 'secondaryLinkage') {
                if (element.link.params.max !== undefined) {
                  this.max = parseInt(element.link.params.max);
                }
                if (element.link.params.noDismiss !== undefined) {
                  this.noDismiss = element.link.params.noDismiss;
                }
                this.secondaryLinkageTitle = element.title;
              } else if (element.link.params.cssType === 'streamingLayout') {
                this.streamingLayoutTitle = element.title;
                this.list = element.subFilterItem; // 初始化数组
                this.list.forEach((item, index) => {
                  item.dropDownList.item.forEach(element => {
                    element['newName'] = item.name;
                    element['newKey'] = item.dropDownList.name;
                  });
                });

              } else if (element.link.params.cssType === 'rangeStreamingLayout') {
                this.rangeStreamingLayoutTitle = element.title;
                this.list = element.subFilterItem; // 初始化数组
                this.list.forEach((item, index) => {
                  item.dropDownList.item.forEach(element => {
                    element['newName'] = item.name;
                    element['newKey'] = item.dropDownList.name;
                  });
                });
              } else if (element.link.params.cssType === 'customArea') {
                this.customAreaTitle = element.title;
                this.list = element.dropDownList.item; // 初始化数组
              } else if (element.link.params.cssType === 'customRent') {
                this.customRentTitle = element.title;
                this.list = element.dropDownList.item;
              } else if (element.link.params.cssType === 'districtLinkage') {
                if (element.link.params.max !== undefined) {
                  this.max = parseInt(element.link.params.max);
                }
                this.districtLinkageTitle = element.title;
              } else if (element.link.params.cssType === 'districtLinkage2') {
                if (element.link.params.max !== undefined) {
                  this.max = parseInt(element.link.params.max);
                }
                this.districtLinkageTitle2 = element.title;
              } else if (element.link.params.cssType === 'brandLinkage') {
                if (element.link.params.max !== undefined) {
                  this.max = parseInt(element.link.params.max);
                }
                this.brandLinkageTitle = element.title;
              }
            }
            this.siftArr.push(element);
          }
        });
      }

      for (let i = 0; i < this.siftArr.length; i++) {
        if (searchArray) {
          if (this.siftArr[i].name === "opportunity_industry_id" && searchArray.industry) {
            this.siftArr[i].title = searchArray.industry;
          }
          if (
            this.siftArr[i].name === "opportunity_district_id" &&
            searchArray.district
          ) {
            this.siftArr[i].title = searchArray.district;
          }
          if (this.siftArr[i].name === "order" && searchArray.order) {
            this.siftArr[i].title = searchArray.order;
          }
        } else {
          if (this.siftArr[i].dropDownList) {
            if (this.siftArr[i].dropDownList.displayName) {
              this.siftArr[i].title = this.siftArr[i].dropDownList.displayName;
            }
            if (this.siftArr[i].type === "filter") {
              // console.log('this.siftArr[' + i + '].type === "filter"=' + this.siftArr[i].dropDownList.value);
              if (this.siftArr[i] && this.siftArr[i]['link'] && this.siftArr[i]['link'].params.initValue) {
                this.result.filter[this.siftArr[i].name] = this.siftArr[i]['link'].params.initValue;
              } else {
                this.result.filter[this.siftArr[i].name] = this.siftArr[i].dropDownList.value;
              }
            }

            // console.log('msg------>', this.siftArr[i].dropDownList);
          } else if (this.siftArr[i].type === "link" && this.siftArr[i].display && this.siftArr[i].display.displayName.length) {
            this.siftArr[i].title = this.siftArr[i].display.displayName;
            this.result.filter[this.siftArr[i].name] = this.siftArr[i].display.value;
          } else if (this.siftArr[i].type === 'modalMultipleSelect' && this.siftArr[i].display.submit && this.siftArr[i].display.displayName.length) {
            this.siftArr[i].title = this.siftArr[i].display.displayName;
            this.result.filter[this.siftArr[i].name] = this.siftArr[i].display.value;
            this.getIndustryData(this.siftArr[i]);
          }
        }
      }
      // 注释以下两行解决高级搜索后自动发了一次submit请求bug  导致搜索结果被覆盖
      // this.message.clearMessage();
      // this.message.sendMessage(this.result);
      if (this.tagData.filterType) {
        this.siftTypeArr = this.tagData.filterType;
        if (this.siftTypeArr.length > 0) {

          // this.siftWidth = ((100 - this.siftTypeArr.length * 2) / this.siftTypeArr.length) + "%";
          const padding = 2.5 + (this.siftTypeArr.length - 1) * 0.625;
          this.siftWidth = 'width: calc((100vw - ' + padding + 'rem) /' + this.siftTypeArr.length + ');';

        }
        // this.showName = this.siftTypeArr.find(v => v.active).value;
        // this.siftTypeArr.forEach(item => {
        //   if (this.showName !== item.value) {
        //     item.active = "1";
        //     // 注释以下解决高级搜索后自动发了一次submit请求bug 导致搜索结果被覆盖
        //     // const timer = setTimeout(() => {
        //     //   this.chooseSiftType(item);
        //     //   clearTimeout(timer);
        //     // }, 10);
        //   }
        // });
        this.result.showName = this.showName;
      }
      // 重新进入页面前判断是否需要记录筛选条件
      const filterTagName = 'needRememberResult' + this.tagData.name;
      if (localStorage.getItem(filterTagName)) {

        const needRememberAllObj = JSON.parse(localStorage.getItem(filterTagName));
        this.siftArr.forEach(v => {
          if (v.needRememberLast === true && needRememberAllObj[v.name] !== undefined) {
            v.title = needRememberAllObj[v.name];
          }
        });
        setTimeout(() => {
          this.message.clearMessage();
          this.message.sendMessage(needRememberAllObj.result);
        }, 300);
      }
    } catch (error) {
      console.log('error----->' + JSON.stringify(error));
    }
  }
  //  协助、
  resSetFilter() {
    const that = this;
    // 将要显示的条件列表加入
    this.siftArr = [];
    this.result.filter = {};
    this.result.order = {};

    this.tagData.filterItems.forEach(element => {
      if (element.indexName && element.indexName === this.selectedIndexName) {
        that.siftArr.push(element);
      } else if (!element.indexName) {
        that.siftArr.push(element);
      }
      if (element.dropDownList && element.dropDownList.item) {
        element.dropDownList.item.forEach(e => {
          delete e.active;
        });
      }
    });

    for (let i = 0; i < this.siftArr.length; i++) {

      if (that.siftArr[i].dropDownList) {
        if (that.siftArr[i].dropDownList.displayName) {
          that.siftArr[i].title = that.siftArr[i].dropDownList.displayName;
        }
        // 条件栏目
        if (!that.siftArr[i].indexName) {
          that.siftArr[i].title = that.selectedIndexDisplayName;
        }
        // 设置默认筛选条件
        if (that.siftArr[i].type === "filter") {
          that.result.filter[that.siftArr[i].name] = that.siftArr[i].dropDownList.value;
        }

        // 设置默认排序条件
        if (that.siftArr[i].type === "order") {
          const name = that.siftArr[i].name;
          const displayName = that.siftArr[i].dropDownList.displayName;
          that.siftArr[i].dropDownList.item.forEach(element => {
            if (element.displayName === displayName) {
              const kSort = {};
              element.sorts.forEach(e => {
                kSort[e.field] = e.value;
              });
              that.result.order.sort = kSort;
            }
          });
        }
      } else if (that.siftArr[i].type === "link" && that.siftArr[i].display && that.siftArr[i].display.displayName.leng) {
        that.siftArr[i].title = that.siftArr[i].display.displayName;
        that.result.filter[that.siftArr[i].name] = that.siftArr[i].display.value;
      }
    }

  }

  // 新的样式用于点击筛选按钮
  siftEventForNewStyle(obj) {
    try {
      const currentPath = localStorage.getItem("tabPath");
      // add by andrew.wen for 首页的筛选需要特殊处理
      if (currentPath !== null && currentPath === 'home/tab1') {

        if (
          document.getElementById('topSegment').getAttribute('isSticky') === null ||
          document.getElementById('topSegment').getAttribute('isSticky') === 'false') {
          let totalScrollHeight = 0;
          const dynamicScrollTop = localStorage.getItem('dynamicScrollTop');
          if (dynamicScrollTop === null || dynamicScrollTop === '0') {
            if (document.getElementsByClassName('buttonNavOneClassName')) {

              totalScrollHeight += document.getElementsByClassName('buttonNavOneClassName')[0]['offsetTop'];
              localStorage.setItem('tab1ScrollToBottomTag', totalScrollHeight + '');
            }
            this.eventService.eventEmit.emit('tab1ScrollToBottom', '1');
          } else {

            const subjectHeight = document.getElementsByClassName('buttonNavOneClassName')[0]['offsetTop'];

            totalScrollHeight = subjectHeight - parseInt(dynamicScrollTop);
          }
          localStorage.setItem('tab1ScrollToBottomTag', totalScrollHeight + '');
          this.eventService.eventEmit.emit('tab1ScrollToBottom', '1');
        }
      }
      setTimeout(() => {
        let pos = JSON.parse(localStorage.getItem("position"));
        // 从数据地图进入时需要校验
        if (localStorage.getItem('mapPosition')) {
          const mapPosition = JSON.parse(localStorage.getItem('mapPosition'));
          if (obj.dropDownList && obj.dropDownList.value === (mapPosition.code + '')) {
            pos = mapPosition;
          }
        }
        this.key = obj.name;
        this.type = obj.type;
        if (this.type === 'link' && obj.display.link) {
          this.ifLink = true;
          this.openFlag = false;
          this.siftObj = obj;
          this.appGlobalService.openBackdrop = false;
          // 城市
          if (obj.display.link.type === 'modal') {
            this.showCityModel(obj.display.link.target);
          } else if (obj.display.link.type === 'searchFillter') {
            const pageParams = {
              pageId: obj.display.link.target,
              params: obj.display.link.params ? obj.display.link.params : {},
              sessionId: localStorage.getItem('sessionId')
            };
            this.showSearchFillterModel(pageParams, this.result);

          } else if (obj.display.link.type === 'page') {
            // 普通页面page
            const pageParams = {
              pageId: obj.display.link.target,
              params: obj.display.link.params ? obj.display.link.params : {},
              sessionId: localStorage.getItem('sessionId')
            };
            this.appGlobalService.goToForward(pageParams);
          }
        } else if (this.type === 'modalMultipleSelect' && obj.display.submit) {
          //   {
          //     "name":"opportunity_project_merchants_city",
          //     "title":"区域",
          //     "order":2,
          //     "type":"modalMultipleSelect",
          //     "needRememberLast":false,
          //     "queryType":null,
          //     "ifCode":0,
          //     "display":{
          //         "value":"1101",
          //         "displayName":"北京",
          //         "submit":{
          //             "id":"selectAllChinaData",
          //             "type":"city"
          //         }
          //     }
          // },
          this.ifLink = true;
          this.openFlag = false;
          this.siftObj = obj;
          this.appGlobalService.openBackdrop = false;
          this.modalMultipleSelect(obj);


        } else if (obj.type === 'department') {
          this.selectDepartment(obj.display.link);
        } else {
          this.ifSecond = !!obj.dropDownList.dropDownList;
          if (this.siftObj === obj) {
            this.openFlag = !this.openFlag;
            this.appGlobalService.openBackdrop = !this.appGlobalService.openBackdrop;
          } else {

            this.siftObj = obj;
            // this.firstLevelList = this.secondLevelList = []; // 初始化
            this.siftArr.forEach(v => {
              v.active = v === obj;
            });
            const params = {
              content: {
                code: obj.ifCode && obj.ifCode + "" === "1" ? pos.code : 0
              },
              id: obj.dropDownList.id,
              sessionId: this.sessionId
            };
            if (this.ifSecond) {
              this.http.post("application/submit", params, res => {
                this.openFlag = true;
                this.appGlobalService.openBackdrop = true;
                this.firstLevelList = this.secondLevelList = []; // 初始化
                this.firstLevelList = res.data.data;
              }, err => {
                this.firstLevelList = this.secondLevelList = []; // 初始化
              });
            } else {
              this.openFlag = true;
              this.appGlobalService.openBackdrop = true;
              this.firstLevelList = this.siftObj.dropDownList.item;
            }
          }
        }
      }, 100);

    } catch (error) {
      console.log('error----->' + JSON.stringify(error));
    }

  }


  /**
   * 点击筛选，获取第一层下拉列表
   * @param obj : '当前点击对象'
   */
  siftEvent(obj, cssType?) {


    // console.log('msg---->:', this.tagData);

    this.siftPanelShowing = true;

    if (cssType !== undefined) {
      this.firstLevelList = null; // 互斥
      this.cssType = cssType;
      this.data = obj;
      if (this.cssType === 'streamingLayout') {
        this.streamingLayoutList = obj.subFilterItem; // 整租、合租
      } else if (this.cssType === 'rangeStreamingLayout') {
        this.rangeStreamingLayoutList = obj.subFilterItem; // 是否住家
      } else if (this.cssType === 'customArea') { // 面积
        this.customAreaList = obj.dropDownList.item;
      } else if (this.cssType === 'customRent') { // 租金
        this.customRentList = obj.dropDownList.item;
      } else if (this.cssType === 'districtLinkage') { // 区域
        this.firstLevelDistrictListNewCssType = obj;
      }
    } else {
      this.cssType = undefined;
      this.data = undefined;
    }
    let pos = JSON.parse(localStorage.getItem("position"));
    // 从数据地图进入时需要校验
    if (localStorage.getItem('mapPosition')) {
      const mapPosition = JSON.parse(localStorage.getItem('mapPosition'));
      if (obj.dropDownList && obj.dropDownList.value === (mapPosition.code + '')) {
        pos = mapPosition;
      }
    }
    this.key = obj.name;
    this.type = obj.type;
    if (this.type === 'link' && obj.display.link) {
      this.ifLink = true;
      this.openFlag = false;
      this.siftObj = obj;
      this.appGlobalService.openBackdrop = false;
      // 城市
      if (obj.display.link.type === 'modal') {
        this.showCityModel(obj.display.link.target);
      } else if (obj.display.link.type === 'searchFillter') {
        const pageParams = {
          pageId: obj.display.link.target,
          params: obj.display.link.params ? obj.display.link.params : {},
          sessionId: localStorage.getItem('sessionId')
        };
        this.showSearchFillterModel(pageParams, this.result);

      } else if (obj.display.link.type === 'page') {
        // 普通页面page
        const pageParams = {
          pageId: obj.display.link.target,
          params: obj.display.link.params ? obj.display.link.params : {},
          sessionId: localStorage.getItem('sessionId')
        };
        this.appGlobalService.goToForward(pageParams);
      }
    } else if (this.type === 'modalMultipleSelect' && obj.display.submit) {
      this.ifLink = true;
      this.openFlag = false;
      this.siftObj = obj;
      this.appGlobalService.openBackdrop = false;
      this.modalMultipleSelect(obj);
    } else if (obj.type === 'department') {
      this.selectDepartment(obj.display.link);
    } else {
      if (obj.dropDownList) {
        this.ifSecond = !!obj.dropDownList.dropDownList;
      } else {
        this.ifSecond = false;
      }
      if (this.siftObj === obj && obj.type !== 'openPage') {
        if (obj && obj.name == "orderList") {
          if (obj.dropDownList.item && obj.dropDownList.item.length >= 2) {
            let tempObj;
            if (obj.selectedValue === undefined) {
              obj.active2 = true;
              obj.selectedValue = obj.dropDownList.item[0].sorts[0].value;
              tempObj = obj.dropDownList.item[0];
            } else {
              if (obj.selectedValue === obj.dropDownList.item[0].sorts[0].value) {
                obj.active2 = false;
                obj.selectedValue = obj.dropDownList.item[1].sorts[0].value;
                tempObj = obj.dropDownList.item[1];
              } else {
                obj.active2 = true;
                obj.selectedValue = obj.dropDownList.item[0].sorts[0].value;
                tempObj = obj.dropDownList.item[0];
              }
            }
            this.getResult(tempObj);
          }
        } else {
          this.openFlag = !this.openFlag;
          this.appGlobalService.openBackdrop = !this.appGlobalService.openBackdrop;
        }
      } else {
        this.siftObj = obj;
        if (obj && obj.name == "orderList") {
          if (obj.dropDownList.item && obj.dropDownList.item.length >= 2) {
            let tempObj;
            if (obj.selectedValue === undefined) {
              obj.active2 = true;
              obj.selectedValue = obj.dropDownList.item[0].sorts[0].value;
              tempObj = obj.dropDownList.item[0];
            } else {
              if (obj.selectedValue === obj.dropDownList.item[0].sorts[0].value) {
                obj.active2 = false;
                obj.selectedValue = obj.dropDownList.item[1].sorts[0].value;
                tempObj = obj.dropDownList.item[1];
              } else {
                obj.active2 = true;
                obj.selectedValue = obj.dropDownList.item[0].sorts[0].value;
                tempObj = obj.dropDownList.item[0];
              }
            }
            this.getResult(tempObj);
          }
        } else {
          this.siftArr.forEach(v => {
            v.active = v === obj;
          });
          if (obj.link !== undefined && obj.link.params && obj.link.params.cssType === 'streamingLayout') {
            this.openFlag = true;
            this.appGlobalService.openBackdrop = true;
            return;

            // 蜂喔用户 1.9.19 新增是否住家区间选择控件
          } else if (obj.link !== undefined && obj.link.params && obj.link.params.cssType === 'rangeStreamingLayout') {
            this.openFlag = true;
            this.appGlobalService.openBackdrop = true;
            return;
          } else if (obj.link !== undefined && obj.link.params && obj.link.params.cssType === 'customArea') {
            this.openFlag = true;
            this.appGlobalService.openBackdrop = true;
            return;
          }
          // this.firstLevelList = this.secondLevelList = []; // 初始化

          const params = {
            content: {
              code: obj.ifCode && obj.ifCode + "" === "1" ? pos.code : 0
            },
            id: obj.dropDownList.id,
            sessionId: this.sessionId
          };


          if (cssType === 'secondaryLinkage' && !this.secondaryLinkage_submit) { // 行业 避免二次请求
            this.ifSecond = false;
          } else if (cssType === 'districtLinkage2' && !this.districtLinkage2_submit) { // 区域 避免二次请求
            this.ifSecond = false;
          } else if (cssType === 'brandLinkage' && !this.brandLinkage_submit) { // 品牌 避免二次请求
            this.ifSecond = false;
          } else if (cssType !== undefined) {
            this.ifSecond = true;
          }


          if (this.ifSecond) {
            this.http.post("application/submit", params, res => {
              this.openFlag = true;
              this.appGlobalService.openBackdrop = true;
              if (cssType !== undefined) {
                // this.firstLevelListNewCssType = res.data.data;
                // this.list = res.data.data;
                if (this.cssType === 'streamingLayout') {
                  // this.streamingLayoutList = res.data.data; // 整租、合租
                } else if (this.cssType === 'rangeStreamingLayout') {
                  // this.rangeStreamingLayoutList = res.data.data;// 是否住家
                } else if (this.cssType === 'customArea') {
                  // this.customAreaList = res.data.data; // 面积
                } else if (this.cssType === 'customRent') {
                  // this.customRentList = res.data.data; // 租金
                } else if (this.cssType === 'districtLinkage') { // 区域
                  this.firstLevelDistrictListNewCssType = res.data.data;
                  if (this.firstLevelDistrictListNewCssType[0] !== undefined && this.firstLevelDistrictListNewCssType[0]['label'] === '不限') {
                    this.firstLevelDistrictListNewCssType[0]['background'] = 'true';
                  }
                  // 
                  if (this.firstLevelDistrictListNewCssType.length > 0 && this.firstLevelDistrictListNewCssType[0]['label'] === '不限') {
                    setTimeout(() => {
                      // fixed bug-view-5767.html
                      if (this.firstLevelDistrictListNewCssType[0] !== undefined && this.firstLevelDistrictListNewCssType[0]['label'] === '不限') {
                        $('#' + this.bigNameId).css('width', 'unset');
                      } else {
                        $('#' + this.bigNameId).css('width', '42%'); //恢复默认值
                        $('#' + this.bigNameId).css('overflow', 'hidden scroll'); //恢复默认值
                      }
                    }, 150);
                  }
                } else if (this.cssType === 'districtLinkage2') { // 区域
                  this.firstLevelDistrictListNewCssType2 = res.data.data;
                  this.districtLinkage2_submit = false;
                  if (this.firstLevelDistrictListNewCssType2[0] !== undefined && this.firstLevelDistrictListNewCssType2[0]['label'] === '不限') {
                    this.firstLevelDistrictListNewCssType2[0]['background'] = 'true';
                  }
                  // 
                  if (this.firstLevelDistrictListNewCssType2.length > 0 && this.firstLevelDistrictListNewCssType2[0]['label'] === '不限') {
                    setTimeout(() => {
                      // fixed bug-view-5767.html
                      if (this.firstLevelDistrictListNewCssType2[0] !== undefined && this.firstLevelDistrictListNewCssType2[0]['label'] === '不限') {
                        $('#' + this.bigNameId).css('width', 'unset');
                      } else {
                        $('#' + this.bigNameId).css('width', '42%'); //恢复默认值
                        $('#' + this.bigNameId).css('overflow', 'hidden scroll'); //恢复默认值
                      }
                    }, 150);
                  }
                } else if (this.cssType === 'secondaryLinkage') { // 行业
                  this.firstLevelListNewCssType = res.data.data;
                  this.secondaryLinkage_submit = false;
                  if (this.firstLevelListNewCssType !== undefined && this.firstLevelListNewCssType[0]['label'] === '不限') {
                    this.firstLevelListNewCssType[0]['background'] = 'true';
                  }
                  if (this.firstLevelListNewCssType.length > 0 && this.firstLevelListNewCssType[0]['label'] === '不限') {
                    setTimeout(() => {
                      // fixed bug-view-5767.html
                      if (this.firstLevelListNewCssType[0] !== undefined && this.firstLevelListNewCssType[0]['label'] === '不限') {
                        $('#' + this.bigNameId).css('width', 'unset');
                      } else {
                        $('#' + this.bigNameId).css('width', '42%'); //恢复默认值
                        $('#' + this.bigNameId).css('overflow', 'hidden scroll'); //恢复默认值
                      }
                    }, 150);
                  }
                } else if (this.cssType === 'multipleSelect3') {//全部分类
                  this.multipleSelect3ListData = res.data.data;
                  this.multipleSelect3FilterName = obj.name;
                } else if (this.cssType === 'brandLinkage') { // 品牌
                  this.brandLinkageData = res.data.data;
                  this.brandLinkage_submit = false;
                }
              } else {
                this.firstLevelList = this.secondLevelList = []; // 初始化
                this.firstLevelList = res.data.data;
              }

            }, err => {
              this.firstLevelList = this.secondLevelList = []; // 初始化
            });
          } else if (cssType === "secondaryLinkage") { // 行业
            this.firstLevelListNewCssType.forEach((e, index) => {
              if (index === 0) {
                e['background'] = true;
              } else {
                e['background'] = false;
              }
            })
            this.bigIndus = {};
          } else if (cssType === "districtLinkage2") { // 区域
            this.firstLevelDistrictListNewCssType2.forEach((e, index) => {
              if (index === 0) {
                e['background'] = true;
              } else {
                e['background'] = false;
              }
            })
            this.bigIndus = {};
          } else {
            if (obj.type === 'openPage') {
              this.openFlag = false;
              this.appGlobalService.openBackdrop = false;
              this.openPage(obj.link);
            } else {
              this.openFlag = true;
              this.appGlobalService.openBackdrop = true;
              if (this.siftObj['link'] && this.siftObj['link'].params.cssType !== 'original') {
                this.siftObj.dropDownList.item.forEach(element => {
                  element['cssType'] = this.siftObj['link'].params.cssType;
                });
              }
              this.firstLevelList = this.siftObj.dropDownList.item;
            }

          }
        }
      }
    }

    // 蜂喔用户1.9.18 
    this.hiddenWheelMsgTag();

  }

  // 点击遮罩层关闭下拉面板
  backdropclick() {
    this.openFlag = false;
  }

  /**
   * 点击第一层下拉列表
   */
  chooseFirstEvent(obj, displayName?) {
    // 1.7.0 新增用于隐藏全选按钮
    if (this.siftObj && this.siftObj['cssStyle'] !== undefined) {
      if (this.siftObj['cssStyle'] === 'hiddenAuditSubmitButtonEvent') {
        this.eventService.eventEmit.emit('hiddenAuditSubmitButton', this.siftObj.title);
      }
    }

    if (this.ifSecond) {
      const params = {
        content: {
          code: obj.value
        },
        id: this.siftObj.dropDownList.dropDownList.id,
        sessionId: this.sessionId
      };
      this.http.post("application/submit", params, res => {
        if (obj.displayName === "全部") {
          this.secondLevelList = [];
          this.secondLevelList.push(res.data.data[0]);
        } else {
          this.secondLevelList = res.data.data;
        }
      });
    } else {
      this.siftPanelShowing = false;
      this.openFlag = false;
      this.appGlobalService.openBackdrop = false;
      // 蜂喔用户1.9.18 新增参数
      this.hiddenWheelMsgTag();
      this.siftArr.forEach(v => {
        if (v === this.siftObj) {
          v.title = obj.displayName;
        }
      });
      if (this.tagData.displayIndex && this.tagData.displayIndex.length > 0) {
        // 获取第一列后面显示隐藏的条件
        let isfirstCol = false;
        this.tagData.displayIndex.forEach(element => {
          // 选中的不是上一次的条件
          if (element.displayName === obj.displayName && element.displayName !== this.selectedIndexDisplayName) {
            isfirstCol = true;
            this.selectedIndexName = element.indexName;
            this.selectedIndexDisplayName = element.displayName;

            // 重置筛选条件
            this.resSetFilter();
            // this.key = obj.name;
            // this.result.filter[obj.name] = obj.value;
            // obj.title = element.displayName;


            this.getResult(obj);
          } else if (element.displayName === obj.displayName && element.displayName === this.selectedIndexDisplayName) {
            isfirstCol = true;
          }
        });
        //  不是第一列
        if (!isfirstCol) {


          this.getResult(obj);

        }
      } else {

        // 1.6.24 版本新增
        if (this.siftObj['nextOrder'] !== undefined) {
          this.askForNextOrder(this.siftObj['nextOrder'], obj.value, obj, displayName);
        } else {
          this.getResult(obj, displayName);
        }



      }





    }
    this.firstLevelList.forEach(v => {
      v.active = v === obj;
    });
    this.fristObj = obj.displayName;
  }


  // 只有当当前控件有nextOrder的时候 才触发
  askForNextOrder(submitId, parent_id, obj, displayName) {

    const params = {
      content: { parent_id },
      id: submitId,
      sessionId: localStorage.getItem('sessionId')
    };
    // 请求获取新数据
    this.http.post('application/submit', params, res => {
      // 请求数据成功 重置区域数据
      if (res.data) {
        console.log('res----', res)
        let subjectSiftObj;
        // item.data = res.data.data;
        this.siftArr.forEach(v => {
          if (v['nextOrder'] === undefined && v['subjectId'] !== undefined) {
            subjectSiftObj = v;
            // console.log(subjectSiftObj);
            subjectSiftObj.dropDownList.item = JSON.parse(res.data.data);
            v = subjectSiftObj;
          }
        });

        if (subjectSiftObj.dropDownList.item.length > 0) {
          const tempObj = { active: true, value: subjectSiftObj.dropDownList.item[0].value, displayName: displayName }
          this.getResult(tempObj, displayName);
          console.log('msg----->', obj);
        }
      } else {
        // 请求数据失败
        this.appGlobalService.showToast(res.message, 2000, 'middle');
      }
    });
  }

  defineArea(obj) {
    const reg = new RegExp(obj.regular);
    if (obj.min && !reg.test(obj.min)) {
      this.appGlobalService.showToast(
        "最小" + obj.title + '--' + obj.message,
        2000,
        "middle"
      );
      return false;
    }
    if (obj.max && !reg.test(obj.max)) {
      this.appGlobalService.showToast(
        "最大" + obj.title + '--' + obj.message,
        2000,
        "middle"
      );
      return false;
    }
    if (obj.min && obj.max && obj.min * 1 > obj.max * 1) {
      this.appGlobalService.showToast(
        "最小" + obj.title + "不能大于最大" + obj.title,
        2000,
        "middle"
      );
      return false;
    }
    this.chooseFirstEvent(obj);
  }

  /**
   * 点击第二层下拉列表
   *
   */
  chooseSecondEvent(obj) {
    obj.active = true;
    this.openFlag = false;
    this.appGlobalService.openBackdrop = false;
    this.secondLevelList.forEach(v => {
      v.active = v === obj;
    });
    this.siftArr.forEach(v => {
      if (v === this.siftObj) {
        if (obj.displayName === "全部") {
          v.title = this.fristObj;
        } else {
          v.title = obj.displayName;
        }
      }
    });
    this.siftPanelShowing = false;
    this.getResult(obj);
    this.hiddenWheelMsgTag();
  }

  hiddenWheelMsgTag() {
    if (this.tagData.needHiddenId !== undefined) {
      this.appGlobalService.needHiddenId = this.tagData.needHiddenId;
      const tagBox = document.getElementById(this.tagData.needHiddenId) as HTMLElement;

      // 蜂喔用户1.9.18
      if (tagBox.style.display === '' || tagBox.style.display === 'block') {
        tagBox.style.display = 'none';

      } else if (tagBox.style.display === 'none' && !this.siftPanelShowing) {
        tagBox.style.display = 'block';
      } else if (tagBox.style.display === 'none' && this.siftPanelShowing && this.appGlobalService.openBackdrop === false) {
        tagBox.style.display = 'block';
      }

      //点击取消遮罩层 上方的tag显示
      this.eventService.eventEmit.on('tagBoxStyle', res => {
        tagBox.style.display = 'block';
      });
    }
  }

  /***
   * 处理日期选择
   * ****/
  // 点击显示前一天月份
  upmonth(e) {
    /*  console.log('月份这里') */
    /*  console.log(this.datetext) */
    if (e === "month") {
      if (this.contrast(this.minDate, this.datepk('month'), 'month', 'down') === true && this.month <= 12 && this.month >= 1) {
        // this.month = this.month - 1;
        const calDate = new Date(this.datetext);
        calDate.setMonth(calDate.getMonth() - 1);
        const tmpMonth = calDate.getMonth() + 1;
        this.month = tmpMonth;
        const tmpYear = calDate.getFullYear();
        this.year = tmpYear;
      } else {
        this.appGlobalService.showToast('已是可查询最低月份', 2000, 'middle');
        return;
      }
      // if (this.month === 0) {
      //   this.month = 12;
      //   // this.year = this.year - 1;
      // }
      this.datepk('month');
      this.tagData.filterItems.forEach(element => {
        if (element.queryType === "dateFilter") {
          this.datelabel = true;
          this.maxDate = element.maxDate;
          this.minDate = element.minDate;
          element.dropDownList.item[0].value = this.datetext;
          element.dropDownList.item[0].active = true;
          element.active = true;
          this.siftEvent(element);
          this.chooseFirstEvent(element.dropDownList.item[0]);
        }
      });
    } else {
      if (this.contrast(this.minDate, this.datepk('month'), 'month', 'down') === true && this.month <= 12 && this.month >= 1) {
        // this.month = this.month - 1;
      } else {
        this.appGlobalService.showToast('已是可查询最低月份', 2000, 'middle');
        return;
      }
      // if (this.month === 0) {
      //   this.month = 12;
      //   this.year = this.year - 1;
      // }
      this.datepk('day');
    }
  }
  // 点击显示后一天月份
  downmonth(e) {
    if (e === "month") {
      if (this.contrast(this.maxDate, this.datepk('month'), 'month', 'up') === false && this.month <= 12 && this.month >= 1) {
        // this.month = this.month + 1;
        const calDate = new Date(this.datetext);
        calDate.setMonth(calDate.getMonth() + 1);
        const tmpMonth = calDate.getMonth() + 1;
        this.month = tmpMonth;
        const tmpYear = calDate.getFullYear();
        this.year = tmpYear;
      } else {
        this.appGlobalService.showToast('已是可查询最高月份', 2000, 'middle');
        return;
      }
      /*  console.log(this.month) */
      // if (this.month === 13) {
      //   this.month = 1;
      //   this.year = this.year + 1;
      // }
      this.datepk('month');
      this.tagData.filterItems.forEach(element => {
        if (element.queryType === "dateFilter") {
          this.datelabel = true;
          this.maxDate = element.maxDate;
          this.minDate = element.minDate;
          element.dropDownList.item[0].value = this.datetext;
          element.dropDownList.item[0].active = true;
          element.active = true;
          this.siftEvent(element);
          this.chooseFirstEvent(element.dropDownList.item[0]);
        }
      });
    } else {
      if (this.contrast(this.maxDate, this.datepk('month'), 'month', 'up') === false && this.month <= 13 && this.month >= 1) {
        // this.month = this.month + 1;
      } else {
        this.appGlobalService.showToast('已是可查询最高月份', 2000, 'middle');
        return;
      }
      // if (this.month === 13) {
      //   this.month = 1;
      //   this.year = this.year + 1;
      // }
      this.datepk('day');
    }
  }
  // 点击显示前一天日期
  dayclick() {
    /*  console.log('昨天这里')
     console.log(this.day) */
    if (this.contrast(this.minDate, this.datepk('day'), 'day', 'up') === true && this.day <= 31 && this.day >= 1) {
      // this.day = this.day - 1;
      // fixed bug 
      const calDate = new Date(this.datetext);
      calDate.setDate(calDate.getDate() - 1);
      this.day = calDate.getDate();
      const tmpMonth = calDate.getMonth() + 1;
      this.month = tmpMonth;
      const tmpYear = calDate.getFullYear();
      this.year = tmpYear;
      this.datepk('day');
      this.tagData.filterItems.forEach(element => {
        if (element.queryType === "dateFilter") {
          this.datelabel = true;
          this.maxDate = element.maxDate;
          this.minDate = element.minDate;
          element.dropDownList.item[0].value = this.datetext;
          element.dropDownList.item[0].active = true;
          element.active = true;
          this.siftEvent(element);
          this.chooseFirstEvent(element.dropDownList.item[0]);
        }
      });
      this.upmonth('day');
    } else {
      this.appGlobalService.showToast('已是可查询最低日期', 2000, 'middle');
      return;
    }

  }
  // 点击显示后一天日期
  dayclick2() {
    if (this.contrast(this.maxDate, this.datepk('day'), 'day', 'down') === false && this.day <= 32 && this.day >= 1) {
      // fixed bug 
      const calDate = new Date(this.datetext);
      calDate.setDate(calDate.getDate() + 1);
      this.day = calDate.getDate();
      const tmpMonth = calDate.getMonth() + 1;
      this.month = tmpMonth;
      const tmpYear = calDate.getFullYear();
      this.year = tmpYear;
      this.datepk('day');
      this.tagData.filterItems.forEach(element => {
        if (element.queryType === "dateFilter") {
          this.datelabel = true;
          this.maxDate = element.maxDate;
          this.minDate = element.minDate;
          element.dropDownList.item[0].value = this.datetext;
          element.dropDownList.item[0].active = true;
          element.active = true;
          this.siftEvent(element);
          this.chooseFirstEvent(element.dropDownList.item[0]);
        }
      });
      // this.downmonth('day');
    } else {
      this.appGlobalService.showToast('已是可查询最高日期', 2000, 'middle');
      return;
    }
  }
  // 返回当前月份有多少天
  monthjisuan(e) {
    if (e === 1 || e === 3 || e === 5 || e === 7 || e === 8 || e === 10 || e === 12) {
      return true;
    } else if (e === 2 && (this.year % 4 === 0 && this.year % 100 !== 0 || this.year % 400 === 0)) {
      return '29';
    } else if (e === 2 && !(this.year % 4 === 0 && this.year % 100 !== 0 || this.year % 400 === 0)) {
      return '28';
    } else {
      return false;
    }
  }
  // 最大最小日期对比
  contrast(firstDate, lastDate, type, classify) {
    if (type === "day" && classify === "up") {
      const arr = firstDate.split("-");
      const firsttime = new Date(arr[0], arr[1], arr[2]);
      const firsttimes = firsttime.getTime();

      const arrs = lastDate.split("-");
      const lasttime = new Date(arrs[0], arrs[1], arrs[2]);
      const lasttimes = lasttime.getTime();
      if (firsttimes >= lasttimes) {
        return false;
      } else {
        return true;
      }
    } else if (type === "day" && classify === "down") {
      const arr = firstDate.split("-");
      const firsttime = new Date(arr[0], arr[1], arr[2]);
      const firsttimes = firsttime.getTime();

      const arrs = lastDate.split("-");
      const lasttime = new Date(arrs[0], arrs[1], arrs[2]);
      const lasttimes = lasttime.getTime();
      if (firsttimes > lasttimes) {
        return false;
      } else {
        return true;
      }
    } else if (type === "month" && classify === "up") {
      // 下个月的
      const arr = firstDate.split("-");
      const firsttime = new Date(arr[0], arr[1]);
      const firsttimes = firsttime.getTime();

      const arrs = lastDate.split("-");
      const lasttime = new Date(arrs[0], arrs[1]);
      const lasttimes = lasttime.getTime();
      if (firsttimes > lasttimes) {
        return false;
      } else {
        return true;
      }
    } else if (type === "month" && classify === "down") {
      // 上个月的
      const arr = firstDate.split("-");
      const firsttime = new Date(arr[0], arr[1]);
      const firsttimes = firsttime.getTime();

      const arrs = lastDate.split("-");
      const lasttime = new Date(arrs[0], arrs[1]);
      const lasttimes = lasttime.getTime();
      if (firsttimes >= lasttimes) {
        return false;
      } else {
        return true;
      }
    }
  }
  // 获取显示的日期
  datepk(e) {
    /*  this.datetext=this.year+"-"+this.month+"+"+this.day; */
    if (this.month < 10 && e === "day" && this.day < 10) {
      /*   console.log(this.year + "-" + '0' + this.month + "-" + '0' + this.day) */
      return this.datetext = this.year + "-" + '0' + this.month + "-" + '0' + this.day;
    } else if (this.month >= 10 && e === "day" && this.day < 10) {
      /*   console.log(this.year + "-" + this.month + "-" + '0' + this.day) */
      return this.datetext = this.year + "-" + this.month + "-" + '0' + this.day;
    } else if (this.month < 10 && e === "day" && this.day >= 10) {
      /*     console.log(this.year + "-" + '0' + this.month + "-" + this.day) */
      return this.datetext = this.year + "-" + '0' + this.month + "-" + this.day;
    } else if (this.month >= 10 && e === "day" && this.day >= 10) {
      /*  console.log(this.year + "-" + this.month + "-" + this.day) */
      return this.datetext = this.year + "-" + this.month + "-" + this.day;
    } else if (this.month < 10 && e === "month") {
      /*  console.log(this.year + "-" + '0' + this.month) */
      return this.datetext = this.year + "-" + '0' + this.month;
    } else if (this.month >= 10 && e === "month") {
      /* console.log(this.year + "-" + this.month) */
      return this.datetext = this.year + "-" + this.month;
    }
  }

  ifadvertisclick(displayName?) {
    this.ifadvertis = !this.ifadvertis;
    if (this.ifadvertis === true) {
      if (displayName && displayName === '全部') {

      } else {
        this.datepk('month');
      }
    } else {
      if (displayName && displayName === '按月') {
        this.datepk('month');
      } else {
        this.datepk('day');
        if (this.contrast(this.maxDate, this.datetext, 'day', 'up') === true) {
          this.datetext = this.maxDate;
          const arrs = this.datetext.split("-");
          // tslint:disable-next-line: radix
          this.year = parseInt(arrs[0]);
          // tslint:disable-next-line: radix
          this.month = parseInt(arrs[1].replace(/^[0]+/, ""));
          // tslint:disable-next-line: radix
          this.day = parseInt(arrs[2]);
          this.datepk('day');
        } else {
          if (this.contrast(this.minDate, this.datetext, 'day', 'down') === false) {
            this.datetext = this.minDate;
            const arrs = this.datetext.split("-");
            // tslint:disable-next-line: radix
            this.year = parseInt(arrs[0]);
            // tslint:disable-next-line: radix
            this.month = parseInt(arrs[1].replace(/^[0]+/, ""));
            // tslint:disable-next-line: radix
            this.day = parseInt(arrs[2]);
            this.datepk('day');
          }
        }
      }
    }

    this.tagData.filterItems.forEach(element => {
      if (element.queryType === "dateFilter") {
        this.datelabel = true;
        this.maxDate = element.maxDate;
        this.minDate = element.minDate;
        element.dropDownList.item[0].value = this.datetext;
        element.dropDownList.item[0].active = true;
        element.active = true;
        this.siftEvent(element);
        if (displayName && displayName === '全部') {
          this.chooseFirstEvent(element.dropDownList.item[0], displayName);
        } else {
          this.chooseFirstEvent(element.dropDownList.item[0], displayName);
        }
      }
    });
  }

  // 处理点击结果
  getResult(obj, dateDisplayName?) {
    const pos = JSON.parse(localStorage.getItem("position"));
    this.result.showName = sessionStorage.getItem('showName') ? sessionStorage.getItem('showName') : this.tagData.keyTag; // 新增默认值
    // 调整条件结构
    const kFilter = "filter";
    const kType = "filter";
    const kOrder = "order";
    const kLocation = "location";
    const kStrSort = "sort";
    if (this.type === "filter") {
      if (obj.cssType !== undefined && (
        obj.cssType === 'secondaryLinkage'
        || obj.cssType === 'districtLinkage'
        || obj.cssType === 'districtLinkage2'
        || obj.cssType === 'streamingLayout'
        || obj.cssType === 'rangeStreamingLayout'
        || obj.cssType === 'customArea'
        || obj.cssType === 'customRent'
        || obj.cssType === "multipleSelect3"
        || obj.cssType === "brandLinkage")) {
        if (obj.cssType === 'secondaryLinkage'
          || obj.cssType === 'districtLinkage' || obj.cssType === 'districtLinkage2' || obj.cssType === "brandLinkage") {
          // 用户输入了最小值如果手动删除最大值已与产品沟通传空串
          this.result[kFilter][this.key] = obj.value;
        } else if (obj.cssType === 'streamingLayout') {
          if (dateDisplayName !== undefined && dateDisplayName.length > 0) {
            dateDisplayName.forEach(element => {
              this.result[kFilter][element.newName] = { [element.newKey]: element.value };
            });
          }
        } else if (obj.cssType === 'rangeStreamingLayout') {
          if (dateDisplayName !== undefined && dateDisplayName.length > 0) {
            dateDisplayName.forEach(element => {
              this.result[kFilter][element.newName] = { [element.newKey]: element.value };
            });
          }
        } else if (obj.cssType === 'customArea' || obj.cssType === 'customRent') {
          if (obj.min === '' && obj.max === '') {
            this.result[kFilter][this.key] = obj.value;
          } else {
            if (obj.min !== undefined || obj.max !== undefined) {
              (obj.min === undefined || obj.min === null) ? obj.min = "0" : obj.min = obj.min;
              // 用户输入了最小值如果手动删除最大值已与产品沟通传空串
              this.result[kFilter][this.key] = obj.min + "," + (obj.max === undefined ? "" : obj.max === null ? "" : obj.max);
            } else {
              this.result[kFilter][this.key] = obj.value;
            }
          }
        }
      } else {
        if (obj.min !== undefined || obj.max !== undefined) {
          (obj.min === undefined || obj.min === null) ? obj.min = "0" : obj.min = obj.min;
          // 用户输入了最小值如果手动删除最大值已与产品沟通传空串
          this.result[kFilter][this.key] = obj.min + "," + (obj.max === undefined ? "" : obj.max === null ? "" : obj.max);
        } else {

          // // 蜂喔商户1.6.19.1 业务领取 找店业务列表新增 普通协助 筛选
          // if (obj['paramValue'] && obj['paramKey'] && this.result[obj['paramKey']]) {
          //   delete this.result['paramKey'];
          // }


          // 新增key value 配置
          if (this.siftObj && obj['paramValue']) {
            if (this.result[obj['paramKey']] !== undefined) {
              if (obj['paramValue'] !== '0') {
                this.result[obj['paramKey']] = obj['paramValue'];
              }
            } else {
              if (obj['paramValue'] !== '0') {
                this.result[obj['paramKey']] = obj['paramValue'];
              } else {
                this.result[obj['paramKey']] = 1;
              }
            }
          }

          // 判断是否需要拆分参数
          if (this.siftObj && this.siftObj['multiplyQuery']) {
            try {
              if (this.result[kFilter]['service_mode']) {
                delete this.result[kFilter]['service_mode'];
              }
              const multiplyParams = obj.value.split(',');
              multiplyParams.forEach(element => {
                const nameValue = element.split(':');
                this.result[kFilter][nameValue[0]] = nameValue[1];
              });
            } catch (error) {
              console.log('error----->' + JSON.stringify(error));
            }
          } else {
            if (!dateDisplayName) {
              if (!this.result[kFilter]) {
                this.result[kFilter] = {};
              }
              this.result[kFilter][this.key] = obj.value;
            } else {
              if (dateDisplayName !== 'multipleSelect3') {
                delete this.result[kFilter];
              }
            }
          }
        }
        if ((obj[kType] && obj[kType] === 1) || obj[kType] === 0) {
          this.result[kFilter][this.key] = obj;
        }
        if (this.result.showName === "#opportunity_rent") {
          if (this.result.filter.opportunity_industry_id) {
            const suitIndustry = this.result.filter.opportunity_industry_id;
            delete this.result.filter.opportunity_industry_id;
            this.result.filter.opportunity_suit_industry = suitIndustry;
          }
        } else {
          // fix by andrew.wen for 后台返回什么参数前端就post什么参数否则无法扩展复用。
          // if (this.result.filter.opportunity_suit_industry) {
          //   const industryId = this.result.filter.opportunity_suit_industry;
          //   delete this.result.filter.opportunity_suit_industry;
          //   this.result.filter.opportunity_industry_id = industryId;
          // }
        }
      }
    } else if (this.type === kOrder) {
      if (this.result[kLocation]) {
        delete this.result[kLocation];
      }

      // 蜂喔1.6.20.2 新增排序参数
      if (this.siftObj && obj['paramValue']) {
        if (this.result[obj['paramKey']] !== undefined) {
          if (obj['paramValue'] !== '0') {
            this.result[obj['paramKey']] = obj['paramValue'];
          }
        } else {
          if (obj['paramValue'] !== '0') {
            this.result[obj['paramKey']] = obj['paramValue'];
          } else {
            this.result[obj['paramKey']] = 1;
          }
        }
      }


      if (obj.displayName) {
        const kSort = {};
        // this.result[kOrder] = {
        //   value: obj.value
        // };
        if (obj.sorts) {
          obj.sorts.forEach(v => {
            kSort[v.field] = v.value;
          });
          this.result[kOrder][kStrSort] = kSort;
        }
        if (obj.needLoaction) {
          this.result[kLocation] = {
            name: "aaa",
            longitude: pos.center.lng,
            latitude: pos.center.lat
          };
        }
      } else {
        this.result[kOrder] = {
          // value: obj.value,
          sort: obj.sort
        };
      }
    }
    localStorage.setItem('siftReqConditionTag', JSON.stringify(this.result));
    // this.message.clearMessage();

    if (this.tagData.search !== undefined) {
      this.result['search'] = this.tagData.search;
    }

    // 发送前判断是否需要记录筛选条件
    const needRememberResult = { result: { filter: {}, order: {} } };
    const filterTagName = 'needRememberResult' + this.tagData.name;
    this.siftArr.forEach(v => {
      if (v.needRememberLast === true) {
        if (v.type === 'filter' && this.result.filter[v.name] !== undefined) {
          needRememberResult.result.filter[v.name] = this.result.filter[v.name];
          needRememberResult[v.name] = v.title;
          if (localStorage.getItem(filterTagName)) {
            const localObj = JSON.parse(localStorage.getItem(filterTagName));
            localObj[v.name] = needRememberResult[v.name];
            localObj.result.filter[v.name] = needRememberResult.result.filter[v.name];
            localStorage.setItem(filterTagName, JSON.stringify(localObj));
          } else {
            localStorage.setItem(filterTagName, JSON.stringify(needRememberResult));
          }

        } else if (v.type === 'filter' && localStorage.getItem(filterTagName) && JSON.parse(localStorage.getItem(filterTagName)).result.filter[v.name] !== undefined) {
          this.result.filter[v.name] = JSON.parse(localStorage.getItem(filterTagName)).result.filter[v.name];
        }

        if (v.type === 'order' && this.result.order !== undefined) {
          if ('{}' !== JSON.stringify(this.result.order)) {
            needRememberResult.result.order = this.result.order;
          }
          needRememberResult[v.name] = v.title;
          if (localStorage.getItem(filterTagName)) {
            const localObj = JSON.parse(localStorage.getItem(filterTagName));
            localObj[v.name] = needRememberResult[v.name];
            if ('{}' !== JSON.stringify(needRememberResult.result.order)) {
              localObj.result.order = needRememberResult.result.order;
            } else if ('{}' !== JSON.stringify(localObj.result.order)) {
              this.result.order = localObj.result.order;
            }
            localStorage.setItem(filterTagName, JSON.stringify(localObj));
          } else {
            localStorage.setItem(filterTagName, JSON.stringify(needRememberResult));
          }

        } else if (v.type === 'order' && localStorage.getItem(filterTagName) && JSON.parse(localStorage.getItem(filterTagName)).result.order !== undefined) {
          this.result.order = JSON.parse(localStorage.getItem(filterTagName)).result.order;
        }
      }
    });

    // todo 新增参数用于筛选。
    if (this.subFilterItem) {
      // orderListTagAskForList
      this.eventService.eventEmit.emit("orderListTagAskForList", this.result);
    } else {
      // 
      if (this.tagData.name === 'filterTagName') {

        if (this.tagData.filterItems[0] && this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params.cssType === 'original') {
          // 1.7.1 赚钱宝如果当前列表页面需要这个ID 则这里需要带这个value
          if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName) {
            this.result[this.tagData.filterItems[0].link.params.keyName] = this.tagData.filterItems[0].link.params.keyValue;
          }
          if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName1) {
            this.result[this.tagData.filterItems[0].link.params.keyName1] = this.tagData.filterItems[0].link.params.keyValue1;
          }
          if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName2) {
            this.result[this.tagData.filterItems[0].link.params.keyName2] = this.tagData.filterItems[0].link.params.keyValue2;
          }
          this.eventService.eventEmit.emit(this.tagData.filterItems[0].link.params.emitTagName, this.result);
        } else {
          // 传递筛选条件
          this.message.sendMessage(this.result);
        }

      } else {
        if (this.tagData.filterItems[0] && this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params.isNeedShowName) {
        } else {
          this.result.showName = undefined;
          delete this.result.showName;
        }
        let emitTagName = this.tagData.name + 'AskForList';

        // 1.7.1 赚钱宝如果当前列表页面需要这个ID 则这里需要带这个value
        if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName) {
          this.result[this.tagData.filterItems[0].link.params.keyName] = this.tagData.filterItems[0].link.params.keyValue;
        }
        if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName1) {
          this.result[this.tagData.filterItems[0].link.params.keyName1] = this.tagData.filterItems[0].link.params.keyValue1;
        }
        if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName2) {
          this.result[this.tagData.filterItems[0].link.params.keyName2] = this.tagData.filterItems[0].link.params.keyValue2;
        }
        if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName3) {
          this.result[this.tagData.filterItems[0].link.params.keyName3] = this.tagData.filterItems[0].link.params.keyValue3;
        }
        if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName4) {
          this.result[this.tagData.filterItems[0].link.params.keyName4] = this.tagData.filterItems[0].link.params.keyValue4;
        }
        if (this.tagData.filterItems[0].link && this.tagData.filterItems[0].link.params && this.tagData.filterItems[0].link.params.keyName5) {
          this.result[this.tagData.filterItems[0].link.params.keyName5] = this.tagData.filterItems[0].link.params.keyValue5;
        }

        if (this.result.filter['opportunity_district_id,opportunity_expect_district'] === undefined || this.result.filter['opportunity_district_id,opportunity_expect_district'] === 'code') {
          delete this.result.filter['opportunity_district_id,opportunity_expect_district'];
        }
        this.eventService.eventEmit.emit(emitTagName, this.result);
      }

    }
  }

  // 用于展示行业 和区域 的双联
  pickerSelect(result, item, isArea?) {
    if (result && result.length && Array.isArray(result)) {
      if (result.length === 1) {
        item.value = result[0].value;
        item.showValue = `${result[0].label}`;
      } else {
        item.value = result[1].value;
        item.showValue = `${result[0].label} ${result[1].label}`;
      }
      if (isArea) {

      }

      //  this.formGroup.patchValue({ [item.formKey]: item.value });
    }

  }

  chooseSiftType(obj, isNewCssType?) {
    // 更新主类别 更新对应的时间选择
    if (obj.filterItem) {
      this.tagData.filterItems.forEach(element => {

        if (element.queryType && element.queryType === 'dateFilter') {
          delete this.result.filter[element.name];
        }
      });

      this.tagData.filterItems = obj.filterItem;
      obj.filterItem.forEach(e => {
        if (obj.queryType === "dateFilter") {
          this.datelabel = true;
          this.maxDate = e.maxDate;
          this.minDate = e.minDate;
          e.dropDownList.item[0].value = this.datetext;
        }
      });
      this.siftArrtwo = [];
      this.siftArrthree = [];
      this.siftArr = [];

      this.tagData.filterItems.forEach(element => {
        // console.log(element);
        if (element.queryType && element.queryType === 'dateFilter') {
          this.siftArrthree.push(element);
          this.result.filter[element.name] = this.datetext;
        } else {
          this.siftArr.push(element);
        }
      });
    }


    if (!obj.isDisabled) {
      const that = this;
      this.openFlag = false;
      this.appGlobalService.openBackdrop = false;
      sessionStorage.setItem("showName", obj.value);
      this.filterType = obj.name;
      this.result.showName = obj.value;
      if (obj.currentCity) {
        this.result[obj.currentCity] = this.currentCity.code;
      }
      this.siftTypeArr.forEach(v => {
        v.active = obj === v ? "1" : "0";
      });
      if (this.result.showName === "#opportunity_rent") {
        if (this.result.filter.opportunity_industry_id) {
          const suitIndustry = this.result.filter.opportunity_industry_id;
          delete this.result.filter.opportunity_industry_id;
          this.result.filter.opportunity_suit_industry = suitIndustry;
        }
      } else {
        if (this.result.filter.opportunity_suit_industry) {
          const industryId = this.result.filter.opportunity_suit_industry;
          delete this.result.filter.opportunity_suit_industry;
          this.result.filter.opportunity_industry_id = industryId;
        }
      }
      // 选下拉条件之前切换转让 / 选址
      if (this.tagData.displayIndex && this.tagData.displayIndex.length > 0) {

        // if (JSON.stringify(this.result.order) === '{}' ) {
        for (let i = 0; i < this.siftArr.length; i++) {
          // 设置默认排序条件
          if (that.siftArr[i].type === "order" && JSON.stringify(this.result.order) === '{}') {
            const displayName = that.siftArr[i].dropDownList.displayName;
            that.siftArr[i].dropDownList.item.forEach(element => {
              if (element.displayName === displayName) {
                const kSort = {};
                element.sorts.forEach(e => {
                  kSort[e.field] = e.value;
                });
                that.result.order.sort = kSort;
              }
            });
          } else if (that.siftArr[i].dropDownList) {
            if (that.siftArr[i].dropDownList.displayName &&
              that.siftArr[i].type === "filter" &&
              that.selectedIndexDisplayName !== that.siftArr[i].dropDownList.displayName &&
              JSON.stringify(this.result.filter) === '{}') {
              // 默认过滤条件
              if (that.siftArr[i].dropDownList.value && that.siftArr[i].name) {
                that.result.filter[that.siftArr[i].name] = that.siftArr[i].dropDownList.value;
              }
              // 城市等跳页面的默认条件
            }
          } else if (that.siftArr[i].type === "link" && that.siftArr[i].display && that.siftArr[i].display.displayName.length) {
            that.siftArr[i].title = that.siftArr[i].display.displayName;
            that.result.filter[that.siftArr[i].name] = that.siftArr[i].display.value;
          }
        }
        // }
      }


      this.message.clearMessage();
      // 传递筛选条件
      this.message.sendMessage(this.result);
    }
  }
  async showSearchFillterModel(pageParams, result) {
    const that = this;
    const modal = await this.modalController.create({
      component: SearchFilterComponent,
      componentProps: { pageParams, result }
    });
    modal.onDidDismiss().then((data) => {
      const value = data.data;
      if (value) {
        this.result = value;
        this.message.clearMessage();
        // 传递筛选条件
        this.message.sendMessage(this.result);
      }
    });
    return await modal.present();
  }

  async showCityModel(target) {
    const that = this;
    const modal = await this.modalController.create({
      component: ChooseCityComponent,
      componentProps: { value: target, noStorage: true, modalTitle: '选择城市' }  //    首页是1 默认不传或者0
    });
    modal.onDidDismiss().then((data) => {
      const value = data.data;
      if (value.n) {
        this.siftObj.title = value.n;
        this.result.filter[this.key] = value.i + '';
        this.message.clearMessage();
        // 传递筛选条件
        this.message.sendMessage(this.result);
      }
    });
    return await modal.present();
  }
  async selectDepartment(link) {
    const modal = await this.modalController.create({
      component: ChooseDepartmentComponent,
      componentProps: { tagData: link, modalTitle: "选择部门" }
    });
    modal.onDidDismiss().then((data) => {

      if (data.data) {
        this.result.filter[this.key] = data.data.code;

        // this.message.clearMessage();
        // 传递筛选条件
        this.message.sendMessage(this.result);

      }
    });
    return await modal.present();
  }

  async getIndustryData(item) {
    const params = {
      content: { type: 'city' },
      id: item.display.submit.id,
      sessionId: localStorage.getItem('sessionId')
    };
    // 请求获取新数据
    await this.http.post('application/submit', params, res => {
      // 请求数据成功 重置区域数据
      if (res.data.data) {
        item.data = res.data.data;
      } else {
        // 请求数据失败
        this.appGlobalService.showToast(res.message, 2000, 'middle');
      }
    });
  }

  // 打开行业模态框 // 多选全国区域
  async modalMultipleSelect(item) {
    const that = this;
    const modal = await this.modalController.create({
      component: ModalOfMultipleComponent,
      componentProps: { data: item }
    });
    modal.onDidDismiss().then(function (data) {
      if (data.data) {
        const selectedData = data.data;
        const selectedLabel = selectedData.map(v => {
          return v.label;
        });
        const selectedValue = selectedData.map(v => {
          return v.value;
        });
        if (data.data.length) {
          // that.formGroup.patchValue({ [item.formKey]: selectedValue.join(',') });
          item.display.value = selectedValue;
          item.display.displayName = selectedLabel;
          that.result.showName = that.showName;
          that.siftObj.title = selectedLabel;
          that.result.filter[that.key] = selectedValue.join(',');
          that.message.clearMessage();
          // 传递筛选条件
          that.message.sendMessage(that.result);

        } else {
          that.result.showName = that.showName;
          item.display.displayName = '区域';
          item.value = '';
          that.siftObj.title = '区域';
          that.result.filter[that.key] = '';
          that.message.clearMessage();
          // 传递筛选条件
          that.message.sendMessage(that.result);
        }
      }
    });
    return await modal.present();
  }




  ngOnDestroy(): void {
    this.message.clearMessage();
    this.eventService.removeCustomListListenersByName('appendResultForSift');
    this.eventService.removeCustomListListenersByName(this.tagData.name + 'AskForList');
    // localStorage.removeItem('needRemberResult');
  }

  // this.openRankingModal("myreal-estate", obj);


  openCustomAreaModal(className, item) {
    const params = {
      sessionId: localStorage.getItem("sessionId"),
      pageId: item.target,
      params: item.params
    };
    this.http.post('application/page', params, async res => {
      const tagData = JSON.parse(res.script).views[0].tags;
      // "ranking-modal"
      const modal = await this.modalController.create({
        showBackdrop: true,
        cssClass: className,
        component: null, // 设置入口组件
        componentProps: { tagData }
      });
      await modal.present();
      // 监听销毁的事件
      const modalData = await modal.onDidDismiss(); // 获取关闭传回的值
      // 返回传回的值，重新调用接口
      console.log(modalData);
      if (modalData.data.itemdata) {
        const newObj = modalData.data.itemdata.link.params;
        Object.assign(newObj, { dateTime: new Date().getTime() });
        const param = {
          viewId: modalData.data.itemdata.link.target,
          params: newObj ? newObj : {},
          sessionId: localStorage.getItem('sessionId')
        };
        console.log(param);
        localStorage.setItem('needRefreshTab1', 'true');
        this.appGlobalService.goToForward(param);
      }
    });
  }

  switchBlockClick(item, className) {
    try {
      item.selected = 'true';
      const nameId = 'home-switch-box-button-' + className;
      const array = document.getElementsByClassName(nameId);

      for (let index = 0; index < array.length; index++) {
        const element = array[index];
        if (item.id === element.id) {
          this.addClass(element, "switch-checked-" + className);
          this.addClass(element.children[0], "home-checked-font-" + className);
          //  参数变动 Object.assign(this.result.filter, item.params);
          // TODO  Object.assign(this.result.filter, item.params.filter);
          const paramKeys = Object.keys(item.params);

          for (let j = 0; j < paramKeys.length; j++) {

            const keyName = paramKeys[j];
            if (keyName !== 'filter') {
              const newParamObj = {};
              newParamObj[keyName] = item.params[keyName];
              Object.assign(this.result, newParamObj);
            } else if (keyName === "filter") {
              this.result.filter = item.params.filter;
            }
          }
        } else {
          this.removeClass(element, "switch-checked-" + className);
          this.removeClass(element.children[0], "home-checked-font-" + className);
        }
      }
      // 提交submit
      this.getResult({ active: true, displayName: '', value: this.result.filter[this.key] });
    } catch (error) {

    }
  }

  /**
   * 添加 class
   */
  addClass(ele, value) {
    if (value) {
      let curValue = this.getClass(ele);
      if (curValue.indexOf(value) === -1) {
        curValue = curValue + " " + value;
      }
      ele.setAttribute("class", curValue.trim());
    }
  }
  /**
   * 删除class
   */
  removeClass(ele, value) {
    if (value) {
      let curValue = this.getClass(ele);
      if (curValue.indexOf(value) > -1) {
        curValue = (" " + curValue + " ").replace(" " + value + " ", " ");
      }
      ele.setAttribute("class", curValue.trim());
    }
  }
  /**
   * 元素是否存在值为@{value}的class
   */
  hasClass(ele, value) {
    let has = false;
    if (value) {
      const curValue = this.getClass(ele);
      if (curValue.indexOf(value) > -1) {
        has = true;
      }
    }
    return has;
  }

  /**
   * 获取class
   */
  getClass(elem) {
    return elem.getAttribute && elem.getAttribute("class") || "";
  }

  // 点击大行业，渲染小行业
  getSmallIndus(big, isFirst?) {
    if (big !== undefined && big.label === '不限') {
      $('#' + this.bigNameId).css('width', 'unset');
    } else {
      $('#' + this.bigNameId).css('width', '42%'); //恢复默认值
      $('#' + this.bigNameId).css('overflow', 'hidden scroll'); //恢复默认值
      if (this.firstLevelListNewCssType !== undefined && this.firstLevelListNewCssType.length > 0) {
        this.firstLevelListNewCssType[0]['background'] = undefined;
      }
      if (this.firstLevelDistrictListNewCssType !== undefined && this.firstLevelDistrictListNewCssType.length > 0) {
        this.firstLevelDistrictListNewCssType[0]['background'] = undefined;
      }
      if (this.firstLevelDistrictListNewCssType2 !== undefined && this.firstLevelDistrictListNewCssType2.length > 0) {
        this.firstLevelDistrictListNewCssType2[0]['background'] = undefined;
      }
    }

    this.bigIndus.background = false;
    this.bigIndus = big;
    this.bigIndus.background = true;
    big.cssType = this.cssType;
    if (this.cssType === 'districtLinkage') {
      // 区域
      this.list = this.firstLevelDistrictListNewCssType;
    } else if (this.cssType === 'districtLinkage2') {
      // 区域
      this.list = this.firstLevelDistrictListNewCssType2;
      if (big.checkLen === undefined) {
        big.checkLen = 0;
      }
    } else if (this.cssType === 'brandLinkage') {
      // 区域
      this.list = this.brandLinkageData;
      if (big.checkLen === undefined) {
        big.checkLen = 0;
      }
    } else {
      // 行业
      this.list = this.firstLevelListNewCssType;
      if (big.checkLen === undefined) {
        big.checkLen = 0;
      }
    }
    if (big.label === '全国' && !isFirst) {
      big.selected = !big.selected;
      if (big.selected) {
        // 清除省份及城市
        this.list.forEach(bigindus => {
          bigindus.checkLen = 0;
          if (bigindus.children) {
            bigindus.children.forEach(element => {
              element.selected = false;
            });
          }

        });
        this.selectIndus = [];
        // 选中全国
        big.checkLen = 1;
        this.selectIndus.push(big);
      } else {
        this.selectIndus = [];
        big.checkLen = 0;
      }
    }
    if (big.value.length === 4 && !isFirst) {
      big.selected = !big.selected;
      if (big.selected) {
        // 清除大区及小商区
        this.list.forEach(bigindus => {
          bigindus.checkLen = 0;
          if (bigindus.children) {
            bigindus.children.forEach(element => {
              element.selected = false;
            });
          }

        });
        this.selectIndus = [];
        // 选中全市
        big.checkLen = 1;
        this.selectIndus.push(big);
        // 清除全国
        if (this.list[0].label === '全国') {
          this.list[0].checklen = 0;
        }

      } else {
        this.selectIndus = [];
        big.checkLen = 0;
      }
    }
    if (big.cssType === 'brandLinkage') {
      if (big.label === '全部' || big.label === '不限') {
        this.list.forEach(bigindus => {
          bigindus.checkLen = 0;
        });
        big.checkLen = 1;
        this.brandArr = [];
        this.brandArr.push(big)
      } else {
        this.checkNum(big, this.list);
      }
    }
  }

  // 选中小行业
  selectSmallIndus(bigindus, item) {

    if (this.cssType === 'districtLinkage') {
      // 区域
      this.list = this.firstLevelDistrictListNewCssType;
    } else if (this.cssType === 'districtLinkage2') {
      // 区域2
      this.list = this.firstLevelDistrictListNewCssType2;
    } else {
      // 行业
      this.list = this.firstLevelListNewCssType;
    }
    // 清除全国 全市
    if (this.list[0].label === '全国' || this.list[0].label === '全市') {
      this.list[0].checkLen = 0;
      this.list[0].selected = false;
      const index = this.selectIndus.findIndex(v => (v.label === '全国' || v.label === '全市'));
      if (index > -1) {
        this.selectIndus.splice(index, 1);
      }
    }

    item.selected = !item.selected;
    if (item.selected) {
      // tslint:disable-next-line:max-line-length
      if ((item.value.length === 2) || (item.value.length === 6)) {
        bigindus.children.forEach(element => {
          if (element.selected) {

            if (bigindus.cssType === "secondaryLinkage") { // 行业
              const index = this.industryArr.findIndex(v => v.value === element.value);
              if (index > -1) { this.industryArr.splice(index, 1); }
            } else if (item.cssType === "districtLinkage2") { // 区域2
              const index = this.region.findIndex(v => v.value === element.value);
              if (index > -1) { this.region.splice(index, 1); }
            } else {
              const index = this.selectIndus.findIndex(v => v.value === element.value);
              if (index > -1) { this.selectIndus.splice(index, 1); }
            }

            element.selected = false;
          }
        });
        bigindus.checkLen = 0;
        this.checkNum(item, bigindus);
        console.log("item.value.length === 2) || (item.value.length === 6)");
      } else {
        //   不包含全市 全行业
        if (!bigindus.children[0].selected || bigindus.children[0].value.length > bigindus.value.length || this.noDismiss !== undefined) {
          this.checkNum(item, bigindus);
          console.log("不包含全市 全行业");
        } else {
          if (item.cssType === "secondaryLinkage") { // 行业
            const index = this.industryArr.findIndex(v => v.value === bigindus.children[0].value);
            this.industryArr.splice(index, 1);
          } else if (item.cssType === "districtLinkage2") { // 区域2
            const index = this.region.findIndex(v => v.value === bigindus.children[0].value);
            this.region.splice(index, 1);
          } else {
            const index = this.selectIndus.findIndex(v => v.value === bigindus.children[0].value);
            this.selectIndus.splice(index, 1);
          }

          bigindus.children[0].selected = false;
          bigindus.checkLen -= 1;
          this.checkNum(item, bigindus);
          console.log("包含全市 全行业");
        }
      }
    } else {
      if (item.cssType === "secondaryLinkage") { // 行业
        const index = this.industryArr.findIndex(v => v.value === item.value);
        this.industryArr.splice(index, 1);
      } else if (item.cssType === "districtLinkage2") { // 区域2
        const index = this.region.findIndex(v => v.value === item.value);
        this.region.splice(index, 1);
      } else {
        const index = this.selectIndus.findIndex(v => v.value === item.value);
        this.selectIndus.splice(index, 1);
      }

      bigindus.checkLen -= 1;
      if (bigindus.checkLen < 0) {
        bigindus.checkLen = 0;
      }
    }
  }

  checkNum(item, bigindus) {
    if (bigindus.cssType === "secondaryLinkage") { // 行业
      if (this.industryArr.length >= this.industryMax) {
        this.appGlobalService.showToast(this.tip1 + this.industryMax + this.tip2, 2000, 'top');
        item.selected = false;
        return;
      } else {
        item.selected = true;
        item['cssType'] = this.cssType;
        this.industryArr.push(item);
        bigindus.checkLen += 1;
      }
    } else if (bigindus.cssType === "districtLinkage2") { // 区域2
      if (this.region.length >= this.max) {
        this.appGlobalService.showToast(this.tip1 + this.max + this.tip2, 2000, 'top');
        item.selected = false;
        return;
      } else {
        item.selected = true;
        item['cssType'] = this.cssType;
        this.region.push(item);
        bigindus.checkLen += 1;
      }
    } else if (item.cssType === "brandLinkage") { // 品牌
      item['cssType'] = this.cssType;
      if (item.checkLen === 0) {
        if (this.list[0].label === '全部' || this.list[0].label === '不限') {
          this.list[0].checkLen = 0;
        }
        if (this.brandArr.length >= this.max) {
          this.appGlobalService.showToast(this.tip1 + this.max + this.tip2, 1500, 'top');
          return;
        } else {
          item.checkLen = 1;
          this.brandArr.push(item);
        }
      } else if (item.checkLen === 1) {
        item.checkLen = 0;
        const index = this.brandArr.findIndex(v => v.value === item.value);
        this.brandArr.splice(index, 1);
      }
      // if (this.brandArr.length >= this.max) {
      //   this.appGlobalService.showToast(this.tip1 + this.max + this.tip2, 2000, 'top');
      //   return;
      // } else {
      //   this.list[0].checkLen = 0;
      //   if (item.checkLen === 0) {
      //     item.checkLen = 1;
      //   } else {
      //     item.checkLen = 0;
      //   }
      //   item['cssType'] = this.cssType;
      //   this.brandArr.push(item);
      // }
    } else {
      if (this.selectIndus.length >= this.max) {
        this.appGlobalService.showToast(this.tip1 + this.max + this.tip2, 2000, 'top');
        item.selected = false;
        return;
      } else {
        item.selected = true;
        item['cssType'] = this.cssType;
        this.selectIndus.push(item);
        bigindus.checkLen += 1;
      }
    }

  }


  reset() {
    
    this.selectIndus = [];
    if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'secondaryLinkage') {
      this.siftObj.title = this.secondaryLinkageTitle;
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'streamingLayout') {
      this.siftObj.title = this.streamingLayoutTitle;
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'rangeStreamingLayout') {
      this.siftObj.title = this.rangeStreamingLayoutTitle; // 是否住家
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'customArea') {
      this.siftObj.title = this.customAreaTitle;
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'customRent') {
      this.siftObj.title = this.customRentTitle;
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'districtLinkage') {
      this.siftObj.title = this.districtLinkageTitle;
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'districtLinkage2') {
      this.siftObj.title = this.districtLinkageTitle2;
    } else if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.cssType === 'brandLinkage') {
      this.siftObj.title = this.brandLinkageTitle;
    }
    if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
      this.siftObj.title = this.siftObj['link'].params.title;
    }
    if (this.cssType === 'secondaryLinkage') {//行业

      this.firstLevelListNewCssType.forEach(e => {

        if (e.children) {
          e.checkLen = 0;
          e.children.forEach(element => {
            if (element.cssType === 'secondaryLinkage') {
              element.selected = false;
            }

          });
        }
      });
      this.industryArr = [];
      if (this.result.filter.opportunity_district_id) {
        delete this.result.filter.opportunity_district_id;
      } else if (this.result.filter.opportunity_expect_district) {
        delete this.result.filter.opportunity_expect_district;
      }
    } else if (this.cssType === 'districtLinkage2') {// 区域2
      this.firstLevelDistrictListNewCssType2.forEach(bigindus => {
        bigindus.checkLen = 0;
        if (bigindus.children) {
          bigindus.children.forEach(element => {
            if (element.cssType === 'districtLinkage2') {
              element.selected = false;
            }
          });
        }
      });
      this.region = [];
      if (this.result.filter['opportunity_district_id,opportunity_expect_district']) {
        delete this.result.filter['opportunity_district_id,opportunity_expect_district'];
      }
    } else if (this.cssType === 'streamingLayout') {// 整租,合租
      this.streamingLayoutList.forEach(item => {
        item.dropDownList.item.forEach(element => {
          element.selected = false;
        });
      });
    } else if (this.cssType === 'rangeStreamingLayout') {// 是否住家
      this.rangeStreamingLayoutList.forEach(item => {
        item.dropDownList.item.forEach(element => {
          element.selected = false;
        });
      });
      this.rangeStreamValue = { lower: '6', upper: '22' };
    } else if (this.cssType === 'customArea') { // 自定义租金
      this.customAreaList.forEach(item => {
        item.selected = false;
      });
      this.maxInputValue = '';
      this.minInputValue = '';
    } else if (this.cssType === 'customRent') { // 自定义面积
      this.customRentList.forEach(item => {
        item.selected = false;
      });
      this.maxRentInputValue = '';
      this.minRentInputValue = '';

    } else if (this.cssType === 'brandLinkage') { // 品牌
      this.brandLinkageData.forEach(item => {
        item.checkLen = 0;
      });
      this.brandArr = [];
      if (this.result.filter.opportunity_district_id) {
        delete this.result.filter.opportunity_district_id;
      }
    }
  }

  dismiss() {
    if (this.minInputValue !== '' && this.maxInputValue === '') {
      this.appGlobalService.showToast("请输入最大值！", 1500, 'middle');
      return;
    } else if (this.minInputValue === '' && this.maxInputValue !== '') {
      this.appGlobalService.showToast("请输入最小值！", 1500, 'middle');
      return;
    } else if (this.minInputValue !== '' && this.maxInputValue !== '') {
      if (this.minInputValue > this.maxInputValue) {
        this.appGlobalService.showToast("最小值不能大于最大值！", 1500, 'middle');
        return;
      } else {
        this.selectIndus[0] = { min: this.minInputValue, max: this.maxInputValue, displayName: this.minInputValue + '-' + this.maxInputValue };
      }
    }


    if (this.minRentInputValue !== '' && this.maxRentInputValue === '') {
      this.appGlobalService.showToast("请输入最大值！", 1500, 'middle');
      return;
    } else if (this.minRentInputValue === '' && this.maxRentInputValue !== '') {
      this.appGlobalService.showToast("请输入最小值！", 1500, 'middle');
      return;
    } else if (this.minRentInputValue !== '' && this.maxRentInputValue !== '') {
      if (this.minRentInputValue > this.maxRentInputValue) {
        this.appGlobalService.showToast("最小值不能大于最大值！", 1500, 'middle');
        return;
      } else {
        this.selectIndus[0] = { min: this.minRentInputValue, max: this.maxRentInputValue, displayName: this.minRentInputValue + '-' + this.maxRentInputValue };
      }
    }

    // 隐藏弹窗
    this.appGlobalService.openBackdrop = false;

    if (this.cssType !== undefined && this.cssType === 'secondaryLinkage') {
      let labelArray = [];
      let valueArray = [];
      if (this.bigIndus && this.bigIndus.label === undefined) {
        valueArray = ['00'];
        this.reset();
      } else if (this.bigIndus.label === "不限") {
        labelArray.push(this.bigIndus.label);
        valueArray.push(this.bigIndus.value);
        this.reset();
      } else if (this.industryArr && this.industryArr.length > 0) {
        this.industryArr.forEach(element => {
          if (element.cssType && element.cssType === 'secondaryLinkage') {
            labelArray.push(element.label);
            valueArray.push(element.value);
          }
        });
      } else {
        this.firstLevelListNewCssType.forEach(e => {
          if (e.background === true || e.background === 'true') {
            labelArray.push(e.label);
            valueArray.push(e.value);
          }
        })
      }
      const obj = { cssType: this.cssType, value: valueArray.toString() };
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.industryArr);
    } else if (this.cssType !== undefined && this.cssType === 'districtLinkage') {
      let labelArray = [];
      let valueArray = [];
      if (this.selectIndus && this.selectIndus.length > 0) {
        this.selectIndus.forEach(element => {
          if (element.cssType && element.cssType === 'districtLinkage') {
            labelArray.push(element.label);
            valueArray.push(element.value);
          }
        });
      }
      const obj = { cssType: this.cssType, value: valueArray.toString() };
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.selectIndus);
    } else if (this.cssType !== undefined && this.cssType === 'districtLinkage2') {
      let labelArray = [];
      let valueArray = [];
      if (this.bigIndus.label === "不限") {
        labelArray.push(this.bigIndus.label);
        valueArray.push(this.bigIndus.value);
        this.reset();
      } else if (this.region && this.region.length > 0) {
        this.region.forEach(element => {
          if (element.cssType && element.cssType === 'districtLinkage2') {
            labelArray.push(element.label);
            valueArray.push(element.value);
          }
        });
      } else {
        this.firstLevelDistrictListNewCssType2.forEach(e => {
          if (e.background === true || e.background === 'true') {
            labelArray.push(e.label);
            valueArray.push(e.value);
          }
        })

      }
      const obj = { cssType: this.cssType, value: valueArray.toString() };
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.selectIndus);
    } else if (this.cssType !== undefined && this.cssType === 'streamingLayout') {
      let labelArray = [];
      let valueArray = [];
      if (this.selectIndus && this.selectIndus.length > 0) {
        this.selectIndus.forEach(element => {
          labelArray.push(element.displayName);
          valueArray.push(element.value);
        });
      }
      const obj = { cssType: this.cssType, value: valueArray.toString() };
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.selectIndus);
    } else if (this.cssType !== undefined && this.cssType === 'rangeStreamingLayout') {// 是否住家
      let labelArray = [];
      let valueArray: any = [];
      const obj = { cssType: this.cssType, value: valueArray, currentArray: this.liveAtHome };
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.liveAtHome);

    } else if (this.cssType !== undefined && this.cssType === 'customArea') {
      let labelArray = [];
      let valueArray = [];
      let obj = { cssType: this.cssType, value: valueArray.toString() };
      if (this.selectIndus && this.selectIndus.length > 0) {
        this.selectIndus.forEach(element => {
          labelArray.push(element.displayName);
          valueArray.push(element.value);
          obj['min'] = element.min;
          obj['max'] = element.max;
          obj.value = element.value;
        });
      }
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.selectIndus);
    } else if (this.cssType !== undefined && this.cssType === 'customRent') {
      let labelArray = [];
      let valueArray = [];
      let obj = { cssType: this.cssType, value: valueArray.toString() };
      if (this.selectIndus && this.selectIndus.length > 0) {
        this.selectIndus.forEach(element => {
          labelArray.push(element.displayName);
          valueArray.push(element.value);
          obj['min'] = element.min;
          obj['max'] = element.max;
          obj.value = element.value;
        });
      }
      if (labelArray.length === 0) {
        if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
          this.siftObj.title = this.siftObj['link'].params.title;
        }
      } else {
        if (labelArray.toString() !== "") {
          this.siftObj.title = labelArray.toString();
        } else {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        }
      }
      this.getResult(obj, this.selectIndus);
    } else if (this.cssType !== undefined && this.cssType === 'brandLinkage') {  // 品牌

      if (this.brandArr[0].label === "不限" || this.brandArr[0].label === "全部") {
        let valueArray = [];
        valueArray.push(this.brandArr[0].value);
        const obj = { cssType: this.cssType, value: valueArray.join(',') };
        this.reset();
        this.getResult(obj, []);
      } else {
        let valueArray = [];
        let labelArray = [];
        this.brandArr.forEach(e => {
          if (e.checkLen === 1) {
            valueArray.push(e.value);
            labelArray.push(e.label)
          }
        })
        const obj = { cssType: this.cssType, value: valueArray.join(',') };
        if (labelArray.length === 0) {
          if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
            this.siftObj.title = this.siftObj['link'].params.title;
          }
        } else {
          if (labelArray.toString() !== "") {
            this.siftObj.title = labelArray.toString();
          } else {
            if (this.siftObj['link'] !== undefined && this.siftObj['link'].params.title !== undefined) {
              this.siftObj.title = this.siftObj['link'].params.title;
            }
          }
        }
        this.getResult(obj, []);
      }
    }
  }

  // 整租 合租 选择事件 
  selectedType(event, it, item, dateIndex, singleMode) {
    event.stopPropagation();
    if (item) {
      if (singleMode === true) { // 单选模式
        item.forEach(element => {
          if (it.value === element.value) {
            element.selected = true;
            element['newName'] = this.streamingLayoutList[dateIndex].name;
            element['newKey'] = this.streamingLayoutList[dateIndex].dropDownList.name;
            this.selectIndus[dateIndex] = element;
          } else {
            element.selected = false;
          }
        });
      } else { // 多选模式
        if (it.displayName === '不限') { // 选中不限
          item.forEach(element => {
            if (it.value === element.value) {
              element.selected = !element.selected;
            } else {
              element.selected = false;
            }
          });
        } else {// 不限之外的按钮
          item.forEach(element => {
            if (it.value === element.value) {
              element.selected = !element.selected;
            } else if (element.displayName === '不限') {
              element.selected = false;
            }
          });
        }
        let labelArray = [];
        let valueArary = [];
        item.forEach(element => {
          if (element.selected === true) {
            labelArray.push(element.displayName);
            valueArary.push(element.value);
          }
        });
        this.selectIndus[dateIndex] = { newName: item[0]['newName'], newKey: item[0]['newKey'], value: valueArary.toString(), displayName: labelArray.toString() };
      }
    }
  }

  // 选择面积 租金
  selectedArea(event, it, singleMode) {
    event.stopPropagation();

    if (this.cssType === 'customRent') {
      // 租金
      this.list = this.customRentList;
      // 与输入框互斥
      this.minRentInputValue = '';
      this.maxRentInputValue = '';
    } else {
      // 与输入框互斥
      this.minInputValue = '';
      this.maxInputValue = '';
      // 面积
      this.list = this.customAreaList;
    }
    if (it) {
      if (singleMode === true) { // 单选模式
        this.list.forEach(element => {
          if (it.value === element.value) {
            element.selected = true;
          } else {
            element.selected = false;
          }
        });
        this.selectIndus[0] = it;
      } else { // 多选
        if (it.displayName === '不限') { // 选中不限
          this.list.forEach(element => {
            if (it.value === element.value) {
              element.selected = !element.selected;
            } else {
              element.selected = false;
            }
          });
        } else {// 不限之外的按钮
          this.list.forEach(element => {
            if (it.value === element.value) {
              element.selected = !element.selected;
            } else if (element.displayName === '不限') {
              element.selected = false;
            }
          });
        }
        let minArray = [];
        let maxArray = [];
        let displayNameArray = [];
        let valueArray = [];
        this.list.forEach(element => {
          if (element.selected === true) {
            if (element.min !== undefined) {
              minArray.push(element.min);
            }
            if (element.max !== undefined) {
              maxArray.push(element.max);
            }
            valueArray.push(element.value);
            displayNameArray.push(element.displayName);
          }
        });
        this.selectIndus[0] = { min: minArray.toString(), max: maxArray.toString(), displayName: displayNameArray.toString(), value: valueArray.toString() };
      }
    }
  }
  // 清除选中所有的面积以及租金
  customAreaRentClick(event, list) {
    event.stopPropagation();
    // 与面积租金按钮互斥
    if (list !== null && list.length > 0) {
      list.forEach(element => {
        element.selected = false;
      });
    }
  }

  // 是否住家
  selectLiveAtHome(event, it, item, dateIndex, singleMode) {
    item.forEach(element => {
      if (it.value === element.value) {
        element.selected = true;
        // this.selectIndus[dateIndex] = element;
        if (this.rangeStreamingLayoutList[dateIndex] && this.rangeStreamingLayoutList[dateIndex].name) {
          element['newName'] = this.rangeStreamingLayoutList[dateIndex].name;
        }
        if (this.rangeStreamingLayoutList[dateIndex] && this.rangeStreamingLayoutList[dateIndex].dropDownList.name) {
          element['newKey'] = this.rangeStreamingLayoutList[dateIndex].dropDownList.name;
        }
        this.liveAtHome[dateIndex] = element;
      } else {
        element.selected = false;
      }
    });
  }

  // 蜂喔用户 1.9.20 新增筛选
  rangeChangeValue(event, item) {
    event.stopPropagation();
    // console.log('selectValue:', item);
    if (this.rangeStreamValue) {
      this.rangeStreamLower = this.rangeStreamValue['lower'];
      this.rangeStreamUpper = this.rangeStreamValue['upper'];
      // 增加筛选条件
    }
    // 组装请求参数
    if (item && item.length > 0) {
      let tempObj = { displayName: '', newKey: '', newName: '', value: '' };
      if (item[1] !== undefined) {
        tempObj.displayName = this.rangeStreamLower + '点到' + this.rangeStreamUpper + '点';
        tempObj.newKey = item[1].dropDownList.name;
        tempObj.newName = item[1].name;
        tempObj.value = this.rangeStreamLower + ',' + this.rangeStreamUpper;
        this.liveAtHome[1] = tempObj;
      }
    }

  }

  openPage(link) {
    this.pageModalService.openPage(link);
  }
}


// demoData() {
//   /* this.tagData = {
//     type: "tag",
//     style: "tag.FilterTagLogic",
//     name: "filterTagName",
//     linearLayout: "header",
//     filterItems: [
//       {
//         name: "opportunity_area",
//         title: "面积",
//         order: 1,
//         type: "filter",
//         queryType: null,
//         ifCode: 0,
//         dropDownList: {
//           id: "dddwbb235ea6-6697-4ade-ae85-4c216b029306",
//           item: [
//             {
//               displayName: "不限",
//               value: "0",
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "20平米以下",
//               value: "1",
//               max: 20,
//               min: 0,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "20-50平米",
//               value: "2",
//               max: 50,
//               min: 20,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "50-100平米",
//               value: "3",
//               max: 100,
//               min: 50,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "100-200平米",
//               value: "4",
//               max: 200,
//               min: 100,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "200-300平米",
//               value: "5",
//               max: 300,
//               min: 200,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "500-1000平米",
//               value: "6",
//               max: 1000,
//               min: 500,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "1000平米以上",
//               value: "7",
//               max: 9999999,
//               min: 1000,
//               type: 1,
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             },
//             {
//               displayName: "自定义",
//               value: "8",
//               type: 1,
//               unit: "平米",
//               title: "面积", // v3.5.0 新增属性 校验提示信息用
//               message: "最多输入6位整数",  // v3.5.0 新增属性 校验提示信息用
//               regular: "^\d{0,6}$", // v3.5.0 新增属性数据填写规则
//               needLoaction: false,
//               isScript: false,
//               isDisabled: false
//             }
//           ]
//         }
//       },
//       {
//         "minDate": "2018-01-01",
//         "maxDate": "2020-07-24",
//         "up": "1.png",
//         "down": "2.png",
//         "value": "2020-07-22",
//         "name": "opportunity_create_time",
//         "title": null,
//         "order": null,
//         "type": "filter",
//         "needRememberLast": false,
//         "queryType": "dateFilter",
//         "ifCode": 0,
//         "dropDownList": {
//           "id": "dddw409163ea-ee72-4000-83ec-6cb3692cd133",
//           "displayName": null,
//           "value": null,
//           "item": [
//             {
//               "displayName": "年月日",
//               "value": "0",
//               "needLoaction": false,
//               "selected": false,
//               "isScript": false,
//               "isDisabled": false
//             }
//           ]
//         }
//       }
//     ]
//   }; */

//   /*  this.tagData={"name":"opportunity_industry_id","title":"行业","order":1,"type":"filter","needRememberLast":false,"queryType":null,"ifCode":0,"dropDownList":{"id":"dddw07cf2563-58c3-401c-9379-95f5fc310beb","dropDownList":{"id":"dddw5f5646a7-8fb0-4d29-8b89-a992ddae1341"}}},{"name":"opportunity_district_id","title":"区域","order":2,"type":"filter","needRememberLast":false,"queryType":null,"ifCode":"1","dropDownList":{"id":"dddwc27a25f2-ea99-4960-ad8b-a92e1319848a","dropDownList":{"id":"dddwab33867d-1b55-4ba1-ae3a-c587e8ce4091"}}},{"name":"opportunity_area","title":"面积","order":3,"type":"filter","needRememberLast":false,"queryType":null,"ifCode":0,"dropDownList":{"id":"dddw0d45293d-6ce1-40eb-910a-8f75a1fa86d5","item":[{"displayName":"不限","value":"0","needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"20平米以下","value":"1","max":20,"min":0,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"20-50平米","value":"2","max":50,"min":20,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"50-100平米","value":"3","max":100,"min":50,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"100-200平米","value":"4","max":200,"min":100,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"200-300平米","value":"5","max":300,"min":200,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"500-1000平米","value":"6","max":1000,"min":500,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"1000平米以上","value":"7","max":9999999,"min":1000,"type":1,"needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false},{"displayName":"自定义","value":"8","type":1,"unit":"平米","needLoaction":false,"title":"面积","selected":false,"isScript":false,"isDisabled":false}]}},{"value":"opportunity_opportunity_status:1;opportunity_refresh_time:-1","name":"order","title":"排序","order":6,"type":"order","needRememberLast":false,"queryType":null,"ifCode":0,"dropDownList":{"id":"dddw7b49afb4-fc85-4b52-9861-49ae7804edc4","displayName":null,"value":null,"item":[{"displayName":"未收费靠前，刷新时间倒序","sorts":[{"field":"opportunity_opportunity_status","value":1,"isScript":false,"isDisabled":false},{"field":"opportunity_refresh_time","value":-1,"isScript":false,"isDisabled":false}],"needLoaction":false,"title":"排序","selected":false,"isScript":false,"isDisabled":false},{"displayName":"已收费靠前，刷新时间倒序","sorts":[{"field":"opportunity_opportunity_status","value":-1,"isScript":false,"isDisabled":false},{"field":"opportunity_refresh_time","value":-1,"isScript":false,"isDisabled":false}],"needLoaction":false,"title":"排序","selected":false,"isScript":false,"isDisabled":false},{"displayName":"未收费靠前，发布时间倒序","sorts":[{"field":"opportunity_opportunity_status","value":1,"isScript":false,"isDisabled":false},{"field":"opportunity_create_time","value":-1,"isScript":false,"isDisabled":false}],"needLoaction":false,"title":"排序","selected":false,"isScript":false,"isDisabled":false},{"displayName":"已收费靠前，发布时间倒序","sorts":[{"field":"opportunity_opportunity_status","value":-1,"isScript":false,"isDisabled":false},{"field":"opportunity_create_time","value":-1,"isScript":false,"isDisabled":false}],"needLoaction":false,"title":"排序","selected":false,"isScript":false,"isDisabled":false},{"displayName":"刷新时间倒序","sorts":[{"field":"opportunity_refresh_time","value":-1,"isScript":false,"isDisabled":false}],"needLoaction":false,"title":"排序","selected":false,"isScript":false,"isDisabled":false},{"displayName":"发布时间倒序","sorts":[{"field":"opportunity_create_time","value":-1,"isScript":false,"isDisabled":false}],"needLoaction":false,"title":"排序","selected":false,"isScript":false,"isDisabled":false}]}},{"minDate":"2018-01-01","maxDate":"2020-07-24","up":"1.png","down":"2.png","value":"2020-07-22","name":"opportunity_create_time","title":null,"order":null,"type":"filter","needRememberLast":false,"queryType":"dateFilter","ifCode":0,"dropDownList":{"id":"dddw409163ea-ee72-4000-83ec-6cb3692cd133","displayName":null,"value":null,"item":[{"displayName":"月","value":"0","needLoaction":false,"selected":false,"isScript":false,"isDisabled":false},{"displayName":"日","value":"1","needLoaction":false,"selected":true,"isScript":false,"isDisabled":false}]}} */
// }

